Prev: NETWORK MARKETING
Next: awk question
From: alexvai on 9 May 2010 04:07 Hi, I need to know the exit status of process by PID in KSH. example: sleep 100 & PID=$! I want to know exit status by this number $PID Thanks
From: Ben Finney on 9 May 2010 05:07 alexvai <alexvaigm(a)gmail.com> writes: > I need to know the exit status of process by PID in KSH. The exit status is only reported to the parent process, as far as I know. -- \ “Only the educated are free.” —Epictetus | `\ | _o__) | Ben Finney
From: Stephane CHAZELAS on 9 May 2010 05:15 2010-05-9, 01:07(-07), alexvai: [...] > I need to know the exit status of process by PID in KSH. > > > example: > > sleep 100 & > > PID=$! > > I want to know exit status by this number $PID [...] wait "$PID" status=$? With a POSIX shell, you can wait(1) the pid even after it's dead to get its exit status that way. So you can do: cmd1 & p1=$! cmd2 & p2=$! cmd3 & p3=$! wait "$p1"; s1=$? wait "$p2"; s2=$? wait "$p3"; s3=$? which should work regardless of which cmd exits last. -- Stéphane
From: alexvai on 9 May 2010 06:39 On May 9, 12:15 pm, Stephane CHAZELAS <stephane_chaze...(a)yahoo.fr> wrote: > 2010-05-9, 01:07(-07), alexvai: > [...]> I need to know the exit status of process by PID in KSH. > > > example: > > > sleep 100 & > > > PID=$! > > > I want to know exit status by this number $PID > > [...] > > wait "$PID" > status=$? > > With a POSIX shell, you can wait(1) the pid even after it's dead > to get its exit status that way. > > So you can do: > > cmd1 & p1=$! > cmd2 & p2=$! > cmd3 & p3=$! > > wait "$p1"; s1=$? > wait "$p2"; s2=$? > wait "$p3"; s3=$? > > which should work regardless of which cmd exits last. > > -- > Stéphane Thanks, it helped me.
From: Barry Margolin on 10 May 2010 02:41 In article <877hnde94q.fsf(a)benfinney.id.au>, Ben Finney <ben+unix(a)benfinney.id.au> wrote: > alexvai <alexvaigm(a)gmail.com> writes: > > > I need to know the exit status of process by PID in KSH. > > The exit status is only reported to the parent process, as far as I > know. Since his script IS the parent, why would that be a problem? -- Barry Margolin, barmar(a)alum.mit.edu Arlington, MA *** PLEASE post questions in newsgroups, not directly to me *** *** PLEASE don't copy me on replies, I'll read them in the group ***
|
Pages: 1 Prev: NETWORK MARKETING Next: awk question |