From: alexvai on
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
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
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
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
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