![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here. |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| help with return codes | ammu | Shell Programming and Scripting | 2 | 02-04-2008 02:57 PM |
| Return Codes | kris01752 | UNIX for Advanced & Expert Users | 3 | 09-25-2006 01:40 PM |
| Return codes | Bab00shka | UNIX for Dummies Questions & Answers | 4 | 02-02-2006 01:46 PM |
| Help with Return codes | leezer1204 | UNIX for Dummies Questions & Answers | 1 | 04-26-2005 01:10 PM |
| Background processes return 127 sporadically | max_largo | Shell Programming and Scripting | 2 | 05-22-2003 02:49 PM |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
||||
|
Checking Return Codes of Background Processes
I'm trying to do the following:
1) Run a bunch of jobs in the background 2) Determine if any one of them returns with a non-zero exit status Here's what I've come up with so far: ########################################## #!/bin/ksh while [ ${#pid_array[*]} -lt 1024 ] do SLEEP_TIME=`expr 1024 - ${#pid_array[*]}` nohup exit_script ${SLEEP_TIME} ${#pid_array[*]} > /dev/null & SAVE_PID=$! echo "PID:${SAVE_PID} SLOT:${#pid_array[*]} SLEEP:${SLEEP_TIME}" pid_array[${#pid_array[*]}]=${SAVE_PID} done jobs -l echo "Waiting..." CNT=0 while [ $CNT -lt ${#pid_array[*]} ] do wait ${pid_array[${CNT}]} echo "PID:${pid_array[${CNT}]} CODE:$?" CNT=`expr $CNT + 1` done exit 0 ########################################## exit_script is just a test program that sleeps for $1 and returns with a code of $2 (mod 256, of course). The problem I'm having is if I perform the wait on a given pid, and that pid is already done, it doesn't always return with the proper code. Specifically, the first 25 will return with the correct code while the rest return with 127, wait's way of saying it doesn't know the code. This leaves me with two questions: 1) Is there a way to make it "remember" more than 25 return codes? 2) Is there a better way to do this? If it matters, this is being ran using ksh on Solaris 8. Thanks for any help you can provide. Joel |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|