LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 04-25-2006, 12:00 PM   #1
gururaj
LQ Newbie
 
Registered: Apr 2005
Posts: 13

Rep: Reputation: 0
Need the return codes of the child processes


Hi,

#!/bin/sh
echo "Parallel Processes Start"
a.sh &
b.sh &
echo "Parallel Processes Created"
wait

here a.sh and b.sh are another shell scripts which has exit status as 0 when the scripts executed successfully and 1 for any abnormal termination.

now after wait i have to run c.sh only when both a.sh and b.sh should have returned 0.

Please advise me how to acheive this.

Thanks in advance
 
Old 04-25-2006, 04:26 PM   #2
macemoneta
Senior Member
 
Registered: Jan 2005
Location: Manalapan, NJ
Distribution: Fedora x86 and x86_64, Debian PPC and ARM, Android
Posts: 4,593
Blog Entries: 2

Rep: Reputation: 344Reputation: 344Reputation: 344Reputation: 344
Well, one way is to:

Code:
echo "-1" > /dev/shm/aRC
echo "-1" > /dev/shm/bRC
(a.sh; echo "$?" > /dev/shm/aRC) &
(b.sh; echo "$?" > /dev/shm/bRC) &
wait
if [ "`/bin/cat /dev/shm/aRC`" == "0" ] && [ "`/bin/cat /dev/shm/bRC`" == "0" ]
then
   c.sh
fi
/bin/rm -f /dev/shm/aRC /dev/shm/bRC
Note the '/dev/shm' is a kernel provided shared memory filesystem. You may not have it available, depending on your release or distribution. You can just use disk files in that case.

I'm sure others will chime in with 100 additional ways to accomplish the same thing.

Last edited by macemoneta; 04-25-2006 at 04:28 PM.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
PPP library & pppd, chat return codes ruchika Linux - Networking 1 03-08-2011 02:50 AM
perl ignore return codes twistedpair Programming 5 02-14-2006 04:54 PM
mprotect() return codes tim_l Programming 2 05-09-2005 07:38 AM
return codes in c exvor Programming 4 01-21-2005 08:45 PM
GNU wget return codes for shell script greenhornet Programming 3 05-09-2004 07:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 01:13 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration