03-28-2014
From the man page:
Quote:
wait [n ...]
Wait for each specified process and return its termination status. Each n may be a process ID or a job specification; if a job spec is given, all processes in that job's pipeline are waited for. If n is not given, all currently active child processes are waited for, and the return status is zero. If n specifies a non-existent process or job, the return status is 127. Otherwise, the return status is the exit status of the last process or job waited for.
9 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
I'm using PERL on windows NT to try to run an extract of data. I have multiple zip files in multiple locations. I am extracting "*.t" from zip files and subsequently adding that file to one zip file so when the script is complete I should have one zip file with a whole bunch of ".t" files in it.
... (2 Replies)
Discussion started by: dangral
2 Replies
2. Shell Programming and Scripting
I am attempting within a for-loop, to have my shell script (Solaris v8 ksh) wait until a copy file command to complete before continueing. The specific code is:
for files in $(<inputfile.lst)
do
mv directory/$files directory/$files
ksh -m -i bg %%
wait $!
done
I am shaky on the... (3 Replies)
Discussion started by: gozer13
3 Replies
3. UNIX for Dummies Questions & Answers
Hi,
Does anyone know how to make BASH provide a list of possible completions on the first tab, and then start cycling through the possibilites on the next tab?
Right now this is what I have in my .bashrc:
bind "set show-all-if-ambiguous on"
bind \\C-o:menu-complete
This allows... (0 Replies)
Discussion started by: Mithu
0 Replies
4. Filesystems, Disks and Memory
Hi All,
Am finding performance of my SD card using hdparm.
hdparm -tT /dev/BlockDev0
/dev/BlockDev0:
Timing cached reads: 1118 MB in 2.00 seconds = 558.61 MB/sec
HDIO_DRIVE_CMD(null) (wait for flush complete) failed: Inappropriate
ioctl for device
Timing buffered disk reads: 14... (0 Replies)
Discussion started by: amio
0 Replies
5. UNIX for Dummies Questions & Answers
When running a command using the >(cmd) syntax in bash how do you wait for the command to complete before moving on in your script?
Here is a simple example:
zcat largefile.gz | tee >(wc && echo “HELLO”) > /dev/null
# I tried wait, here but it doesn't wait for the process in the subshell.... (8 Replies)
Discussion started by: mrvwman
8 Replies
6. Shell Programming and Scripting
I have a script that runs a console/terminal command on the server and what is want is for each of the multiple success reports fed back from the clients (echo-ed out onto the conosle) to be counted and after x number of reports reboot the server.
The Details:
The command (program) is... (0 Replies)
Discussion started by: dp123
0 Replies
7. Shell Programming and Scripting
Let's say I start process A.sh, then start process B.sh. I call both of them in my C.sh
How can I make sure that B starts its execution only after A.sh finishes.
I have to do this in loop.Execution time of A.sh may vary everytime.
It is a parameterized script. (17 Replies)
Discussion started by: rafa_fed2
17 Replies
8. Shell Programming and Scripting
Hi All,
I have a question related to Shell scripting. In my shell script, I have following two commands in sequence:
sed 's/^/grep "^120" /g' $ORIGCHARGEDAMTLIST|sed "s;$;| cut -f$FIELD_NO1 -d '|' | awk '{ sum+=\$1} END {printf (\"%0.2f\\\n\", sum/100)}' >$TEMPFILE
mv $TEMPFILE $ORIGFILE... (3 Replies)
Discussion started by: angshuman
3 Replies
9. Shell Programming and Scripting
Hello all,
I tried to parralise my treatments but after a while 'ps -ef' display all child process <defunct> (zombie)
Parent bash script to process all files (>100000) in directory:
for filename in /Data/*.txt; do
./child_pprocess.sh $filename &
done
exit(0)I understand that the... (1 Reply)
Discussion started by: namnetes
1 Replies
WAIT(2) System Calls Manual WAIT(2)
NAME
wait, waitpid - wait for process to terminate
SYNOPSIS
#include <sys/types.h>
#include <sys/wait.h>
pid_t wait(int *status)
pid_t waitpid(pid_t pid, int *status, int options)
DESCRIPTION
Wait causes its caller to delay until a signal is received or one of its child processes terminates. If any child has died since the last
wait, return is immediate, returning the process id and exit status of one of the terminated children. If there are no children, return is
immediate with the value -1 returned.
On return from a successful wait call, status is nonzero, and the high byte of status contains the low byte of the argument to exit sup-
plied by the child process; the low byte of status contains the termination status of the process. A more precise definition of the status
word is given in <sys/wait.h>. If wait can called with a null pointer argument to indicate that no status need be returned.
Waitpid provides an alternate interface for programs that must not block when collecting the status of child processes, or that wish to
wait for one particular child. The pid parameter is the process ID of the child to wait for, -1 for any child. The status parameter is
defined as above. The options parameter is used to indicate the call should not block if there are no processes that wish to report status
(WNOHANG), and/or that children of the current process that are stopped due to a SIGTTIN, SIGTTOU, SIGTSTP, or SIGSTOP signal should also
have their status reported (WUNTRACED). (Job control is not implemented for Minix, but these symbold and signals are.)
When the WNOHANG option is specified and no processes wish to report status, waitpid returns -1 with errno set to EAGAIN. The WNOHANG and
WUNTRACED options may be combined by or'ing the two values.
NOTES
The call wait(&status) is equivalent to waitpid(-1, &status, 0).
See sigaction(2) for a list of termination statuses (signals); 0 status indicates normal termination. A special status (0177) is returned
for a stopped process that has not terminated and can be restarted; see ptrace(2). If the 0200 bit of the termination status is set, a
core image of the process was produced by the system.
If the parent process terminates without waiting on its children, the initialization process (process ID = 1) inherits the children.
<sys/wait.h> defines a number of macros that operate on a status word:
WIFEXITED(status)
True if normal exit.
WEXITSTATUS(status)
Exit status if the process returned by a normal exit, zero otherwise.
WTERMSIG(status)
Signal number if the process died by a signal, zero otherwise.
WIFSIGNALED(status)
True if the process died by a signal.
WIFSTOPPED(status)
True if the process is stopped. (Never true under Minix.)
WSTOPSIG(status)
Signal number of the signal that stopped the process.
RETURN VALUE
If wait returns due to a stopped or terminated child process, the process ID of the child is returned to the calling process. Otherwise, a
value of -1 is returned and errno is set to indicate the error.
Waitpid returns -1 if there are no children not previously waited for, if the process that it wants to wait for doesn't exist, or if WNO-
HANG is specified and there are no stopped or exited children.
ERRORS
Wait will fail and return immediately if one or more of the following are true:
[ECHILD] The calling process has no existing unwaited-for child processes.
[EFAULT] The status argument points to an illegal address.
[EAGAIN] Waitpid is called with the WNOHANG option and no child has exited yet.
SEE ALSO
execve(2), exit(2), sigaction(2).
4th Berkeley Distribution June 30, 1985 WAIT(2)