Catch exit code of specific background process | Unix Linux Forums | Shell Programming and Scripting

  Go Back    

Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

Catch exit code of specific background process

Shell Programming and Scripting

Closed Thread    
Thread Tools Search this Thread Display Modes
Old 01-30-2013
Xedrox Xedrox is offline
Registered User
Join Date: Dec 2011
Last Activity: 5 September 2014, 4:05 PM EDT
Posts: 28
Thanks: 4
Thanked 0 Times in 0 Posts
Catch exit code of specific background process

Hi all, i hava a specific backgroud process. I have de PID of this process. At some time, the process finish his job, is there any way to catch the exit code? I use "echo $?" normally for commands.

Sponsored Links
Old 01-30-2013
neutronscott's Avatar
neutronscott neutronscott is offline Forum Advisor  
script kiddie
Join Date: Jun 2011
Last Activity: 24 October 2014, 12:54 AM EDT
Location: McMurdo Station, Antarctica
Posts: 813
Thanks: 28
Thanked 242 Times in 228 Posts
Have a look at wait

mute@clt:~$ { sleep 30; exit 123; } &
[1] 24619
mute@clt:~$ wait 24619
[1]+  Exit 123                { sleep 30; exit 123; }
mute@clt:~$ echo $?

of course, wait blocks...
Sponsored Links
Old 01-30-2013
Yoda's Avatar
Yoda Yoda is offline Forum Advisor  
Jedi Master
Join Date: Jan 2012
Last Activity: 22 October 2014, 8:12 PM EDT
Location: Galactic Empire
Posts: 3,387
Thanks: 235
Thanked 1,209 Times in 1,135 Posts
Use wait

wait <PID>

EDIT: too late...
Sponsored Links
Closed Thread

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Catch Zombie Process ckwan AIX 1 11-03-2011 04:36 AM
Background process, return code and pid. RECrerar Shell Programming and Scripting 5 08-13-2011 05:30 AM
catch a particular word from a specific line -perlscript pspriyanka Shell Programming and Scripting 2 06-15-2011 01:03 AM
Return code of background process c19h28O2 Shell Programming and Scripting 3 04-06-2008 11:46 AM
background process return code Vikas Sood Shell Programming and Scripting 5 06-10-2006 09:25 AM

All times are GMT -4. The time now is 03:47 AM.