Discussion:
Exit code of process run using truss
(too old to reply)
neoganesh
19 years ago
Permalink
How can we find the exit code of the process that we run using the
truss command. If i check the value of $? i get the exit code for the
truss command and not for the process started using truss.

I see that in HP-UX the -k option helps out in this case. When this
option is used, tusc exits with the exit code of the process that was
last traced.

Please help.

Thanks in Advance
mmsganesh
neoganesh
19 years ago
Permalink
Can some1 help on this please
Post by neoganesh
How can we find the exit code of the process that we run using the
truss command. If i check the value of $? i get the exit code for the
truss command and not for the process started using truss.
I see that in HP-UX the -k option helps out in this case. When this
option is used, tusc exits with the exit code of the process that was
last traced.
Please help.
Thanks in Advance
mmsganesh
mmsganesh
19 years ago
Permalink
Post by neoganesh
How can we find the exit code of the process that we run using the
truss command. If i check the value of $? i get the exit code for the
truss command and not for the process started using truss.
I see that in HP-UX the -k option helps out in this case. When this
option is used, tusc exits with the exit code of the process that was
last traced.
Please help.
Thanks in Advance
mmsganesh
j3
19 years ago
Permalink
Post by neoganesh
How can we find the exit code of the process that we run using the
truss command. If i check the value of $? i get the exit code for the
truss command and not for the process started using truss.
I see that in HP-UX the -k option helps out in this case. When this
option is used, tusc exits with the exit code of the process that was
last traced.
Please help.
Thanks in Advance
mmsganesh
Curiously the exit status for truss does not appear to be defined (at
http://publib.boulder.ibm.com/infocenter/pseries/v5r3/index.jsp?topic=/com.ibm.aix.doc/infocenter/base/aixinformation.htm).
I suspect that it will always return 0 if it finds and executes the
command. It looks like it returns 2 if no command is found or an
invalid flag is specified.
To capture the exit code of your program you will have to scan the
output of truss, eg
truss false 2>&1 | awk -F'[()]' '{status=$1} END {print status}'
The awk script is there to expect a final line like "_exit(1)" and
print the value within parentheses, ie "1". Note that this was done
from a ksh prompt. If you don't want to redirect stderr to stdout you
could use the -o flag instead and process that output file with the awk
command after the truss command has completed, ie truss and awk on
separate lines.
Hope this helps.
Jeffrey

Continue reading on narkive:
Loading...