sh - unix AIX - get the status of a child background process in the parent shell script -


i have parent shell calls child shell background process. in child shell send exit parent , required capture status of child in parent process. using "jobs" command same. able capture running status of child , dont done status in parent. please find below code , output -

parent shell:

#!/bin/ksh date ./sleep.com& echo $? echo $! pid=$! echo $pid jobs $pid wait $pid jobs $pid echo $pid 

child shell (sleep.com- background process):

#!/bin/ksh sleep 8 exit 10 

output of execution-

september 11, 2017 @ 07:58:17 pm  0 12517444 12517444 [1] +  running                 <command unknown> ./parent.com[10]: jobs: no such job 12517444 

please me capture status of jobs command post completion of child.

in case error:

./parent.com[10]: jobs: no such job

thanks & regards

himanshu agrawal.

try wait -n:

#!/bin/ksh set -v date ./sleep.com& echo $? pid=$! echo $pid wait -n $pid child_exit=$? printf 'child exited code %d\n' "$child_exit" 

Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -