Sponsored Content
Top Forums UNIX for Dummies Questions & Answers Implement the '&&' function in a shell Post 302883391 by Yongfeng on Monday 13th of January 2014 10:16:32 PM
Old 01-13-2014
Hello Don, thanks so much for your reply. I'm using Advanced Programming in the Unix Environment and Modern Operating Systems as my reference.

As for the question, I just want the parent to get the command execution result(successful or not) from the child, because I want to do &&(conditional execution). If execvp successfully executes in the child, how does the parent know it because it does not return any value. Thanks.
 

10 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

subshell & background function

Hello all, Can someone explain to me the advantage between using subshell over a function call in scripts? To me these are the same. Am I wrong to think this? (4 Replies)
Discussion started by: larry
4 Replies

2. Shell Programming and Scripting

Array split function & hashes

Hi, If this is the array that is being returned to me: How would I get the values for each of the 3 records? This works for 1 Record: foreach $item (@results) { ($id, $id2, $name, $date, $email) = split(/\|/, $item, 5); print "$name<br>"; } (2 Replies)
Discussion started by: novera
2 Replies

3. UNIX for Advanced & Expert Users

Network Shell Script & Blade Logic & Network Security

I am going to take up a position in Data & Network Security. I would need to write network shell scripts doing the following task: Going to around 2000 servers and findout which groups has access to each servers and which ids are there in each group that has access. I need to implement... (1 Reply)
Discussion started by: pinnacle
1 Replies

4. Shell Programming and Scripting

Shell Script to display function names (called & defined) in a C++ Source Code

Hello to all, I am looking for a way to display only the names of function (calls & definition) of a C++ source code.There is already a post related to this, but the script is to find the functions using a specific variable, and the replies are not that convincing since they cannot be used for... (2 Replies)
Discussion started by: frozensmilz
2 Replies

5. Shell Programming and Scripting

PHP read large string & split in multidimensional arrays & assign fieldnames & write into MYSQL

Hi, I hope the title does not scare people to look into this thread but it describes roughly what I'm trying to do. I need a solution in PHP. I'm a programming beginner, so it might be that the approach to solve this, might be easier to solve with an other approach of someone else, so if you... (0 Replies)
Discussion started by: lowmaster
0 Replies

6. Shell Programming and Scripting

replace & with &amp; xml file

Hello All I have a xml file with many sets of records like this <mytag>mydata</mytag> <tag2>data&</tag2> also same file can be like this <mytag>mydata</mytag> <tag2>data&</tag2> <tag3>data2&amp;data3</tag3> Now i can grep & and replace with &amp; for whole file but it will replace all... (4 Replies)
Discussion started by: lokaish23
4 Replies

7. Shell Programming and Scripting

Replace & sign to &amp word

Hi, I have text file abc.txt. In this file, I have the following data. Input: Mr Smith &amp Mrs Smith Mr Smith &apos Mrs Smith Mr Smith & Mrs Smith Mr Smith& Mrs Smith Mr Smith &Mrs Smith Output: Mr Smith &amp Mrs Smith Mr Smith &apos Mrs Smith Mr Smith &amp Mrs Smith Mr Smith&amp... (4 Replies)
Discussion started by: naveed
4 Replies

8. UNIX for Dummies Questions & Answers

MAN and read & write function

How to use MAN to find information about read() and write() function ? The command "man read" show some rubbish, for example "man open" show great information about function I need. (2 Replies)
Discussion started by: bbqtoss
2 Replies

9. Shell Programming and Scripting

SFTP Shell Script Get & Delete && Upload & Delete

Hi All, Do you have any sample script, - auto get file from SFTP remote server and delete file in remove server after downloaded. - only download specify filename - auto upload file from local to SFTP remote server and delete local folder file after uploaded - only upload specify filename ... (3 Replies)
Discussion started by: weesiong
3 Replies

10. Homework & Coursework Questions

How to Dynamically Pass Parameter to plsql Function & Capture its Output Value in a Shell Variable?

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: 2. Relevant commands, code, scripts, algorithms: #! /bin/ksh v="ORG_ID" ... (2 Replies)
Discussion started by: sujitdas2104
2 Replies
FORK1(9)						   BSD Kernel Developer's Manual						  FORK1(9)

NAME
fork1 -- create a new process SYNOPSIS
#include <sys/types.h> #include <sys/proc.h> int fork1(struct lwp *l1, int flags, int exitsig, void *stack, size_t stacksize, void (*func)(void *), void *arg, register_t *retval, struct proc **rnewprocp); DESCRIPTION
fork1() creates a new process out of the process behind l1, which is assumed to be the current lwp. This function is used primarily to implement the fork(2) and vfork(2) system calls, but is versatile enough to be used as a backend for e.g. the __clone(2) call. The flags argument controls the semantics of the fork operation, and is made up of the bitwise-OR of the following values: FORK_PPWAIT The parent process will sleep until the child process successfully calls execve(2) or exits (either by a call to _exit(2) or abnormally). FORK_SHAREVM The child process will share the parent's virtual address space. If this flag is not specified, the child will get a copy- on-write snapshot of the parent's address space. FORK_SHARECWD The child process will share the parent's current directory, root directory, and file creation mask. FORK_SHAREFILES The child process will share the parent's file descriptors. FORK_SHARESIGS The child process will share the parent's signal actions. FORK_NOWAIT The child process will at creation time be inherited by the init process. FORK_CLEANFILES The child process will not copy or share the parent's descriptors, but rather will start out with a clean set. A flags value of 0 indicates a standard fork operation. The exitsig argument controls the signal sent to the parent on child death. If normal operation desired, SIGCHLD should be supplied. It is possible to specify the child userspace stack location and size by using the stack and stacksize arguments, respectively. Values NULL and 0, respectively, will give the child the default values for the machine architecture in question. The arguments func and arg can be used to specify a kernel function to be called when the child process returns instead of child_return(). These are used for example in starting the init process and creating kernel threads. The retval argument is provided for the use of system call stubs. If retval is not NULL, it will hold the following values after successful completion of the fork operation: retval[0] This will contain the pid of the child process. retval[1] In the parent process, this will contain the value 0. In the child process, this will contain 1. User level system call stubs typically subtract 1 from retval[1] and bitwise-AND it with retval[0], thus returning the pid to the parent process and 0 to the child. If rnewprocp is not NULL, *rnewprocp will point to the newly created process upon successful completion of the fork operation. RETURN VALUES
Upon successful completion of the fork operation, fork1() returns 0. Otherwise, the following error values are returned: [EAGAIN] The limit on the total number of system processes would be exceeded. [EAGAIN] The limit RLIMIT_NPROC on the total number of processes under execution by this user id would be exceeded. SEE ALSO
execve(2), fork(2), vfork(2) BSD
January 4, 2008 BSD
All times are GMT -4. The time now is 04:32 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy