How to check the killed process"s exit code.

How to check the killed process"s exit code.

am 20.09.2007 04:00:50 von empriser

kill 12345
How to check the process 12345 exit code ?

I have a client computer and a server computer. I run a command in
server from client using rsh command. When I kill the runing process
in server, the client process rsh return exit code 0. I want to check
the exit code of process in server that have killed by me.

Re: How to check the killed process"s exit code.

am 20.09.2007 09:49:58 von Stephane CHAZELAS

2007-09-20, 02:00(-00), empriser:
> kill 12345
> How to check the process 12345 exit code ?
>
> I have a client computer and a server computer. I run a command in
> server from client using rsh command. When I kill the runing process
> in server, the client process rsh return exit code 0. I want to check
> the exit code of process in server that have killed by me.

Yes, rsh doesn't transfer the exit status of the remote command
to the local machine.

ssh does, so if that's an option you may want to switch.
Otherwise, you may do instead of

rsh somehost '/path/to/my_server'
echo "Exit status was $?"

(which in that case returns 0 unless *rsh* fails)

{
status=$(
rsh somehost '
/path/to/my_server >&2
echo "$?"
'
)
} 2>&1
echo "Exit status was $status"

As rsh opens two channels, one for stdout, one for stderr. The
above makes all the stdout and stderr go to the local stdout so
that the remote stdout can be used to carry the exit status.

This assumes that the user who is executing this has a
Bourne-like shell as its login shell on the remote host.

--
Stéphane