If pid is not an active process ID, the wait utility will return immediately and the return code will be 0.
i just came across this which means that wait will returm 0 even though the script has failed so can anyone tell me what is the exact way to get the return status from wait command in bash script ?
Not exactly. If I run the bash script (from a file named nonzero):
I get the output:
The second line of the above output shows that I do get the exit code from a child that died before I called wait as long as its exit status hadn't already been reaped. The line in blue was a diagnostic written by the shell, not directly produced by the script. The final 127 exit status is an indication that you tried to wait for a child that was not your child or that you had already collected its exit status. You will only get a zero exit status if the child whose status wait collected exited with a zero exit status. (Note that if you kill a process and it is catching the signal you sent; it may still exit with a zero exit status.)
These 2 Users Gave Thanks to Don Cragun For This Post:
Ok, heres the situation. We use Solaris 8 and sometimes users who are logged into our system restart their pc's without shutting down the application that attached to our unix backend. I netstat and I get time-waits for the users.
My question is how long before the time-wait ends and the user... (1 Reply)
I have a few xml files and I want to input say 5 parameters within each file. is it possible to do so with sed?
<parameter>A</parameter>
<parameter>B</parameter>
....
....
And so on.
These parameters are meant to go in just inside:
<?xml... (2 Replies)
Hello,
I am trying to write a script that has a option of restarting the script from where it failed. I have to write a script called Batch.sh. This script has to run quite a few sql files as shown below:
logcmd.sh -f test1.sql
logcmd.sh -f test2.sql
logcmd.sh -f test3.sql
logcmd.sh -f... (4 Replies)
:cool:
I need to execute a shell script to do the following:
cat a file
run two back ground processes using the first two values from the file
wait till those background processes finish
run two more background processes using the next two values from the file
wait till those background... (1 Reply)
i have a function defined in one ksh
i want to use the same functionality in another ksh
i am using
. ../<ksh name>
but it is not picking that functionality
what i have to do for the same (2 Replies)
Did not use 'wait' yet.
How I understand by now the wait works only for child processes, started background.
Is there any other way to watch completion of any, not related process (at least, a process, owned by the same user?)
I need to start a background process, witch will be waiting... (2 Replies)
HI,
I have a strange problem. A shell script that runs fine on solaris. when i ported to linux, it started hanging.
here is the core of the script
CFG_FILE=tab25.cfg
sort -t "!" -k 2 ${CFG_FILE} | egrep -v "^#|^$" | while IFS="!" read a b c
do
#echo "jobs output"
#jobs
#echo "jobs... (13 Replies)
Hi,
I am facing a strange issue,
when i call a script from my while loop in background it doesnt go in background, despite the wait i put below the whil loop it goes forward even before the process put in background is completed.
cat abc.txt | while read -u4 line
do
#if line contains #... (2 Replies)
Hi everyone, today i need that someone help to understand this particular line of command.
So you can explain to me step by step, it will be great.
---------- Post updated at 11:53 AM ---------- Previous update was at 11:51 AM ---------- (9 Replies)
Hi ,
I've written the following code to zip the big file
$dir_temp ="/home/etc/hst
zip -r $dir_temp/file_nm.zip $dir_temp/file_nm
The zip file has been created . When I try to UNZIP the file
with the following command
unzip file_nm.zip
The file got unzipped but created in the... (3 Replies)