perl system() exit code 36096

857 views Asked by At

I am trying to find the meaning of exit code 36096 from the following system() call to ksh script.

$proc_ret = system("/path/to/shellscript.sh"); 

$proc_ret returns "36096"

I have checked the output of shellscript.sh, It run fine until the another shell script (status.sh) inside shellscript.sh was invoked. only the first line of that script was invoked, the rest of the script was not get invoked.

here is the content of status.sh

echo "a" > /tmp/a
echo "complete."
echo "b" >> /tmp/a
cat /path/to/mail.txt | mail -s "subject" email@domain
echo "mail complete."
echo "c" >> /tmp/a

I don't know why the script did not continue after the first line. the exit code of system call made to shellscript.sh looks strange to me. If anyone know the meaning of 36096 then please let me know.

1

There are 1 answers

0
Jens On BEST ANSWER

Note that 36096 is 141 * 256. As the system docs tell you, 141 is the exit status of the program. Note again, that an exit status >128 from a shell often means that the child process was killed due to a signal. That signal is obtained by subtracting 128 from the exit status (i.e. look at the low 7 bits).

So the script got signal 13, which is SIGPIPE - write on a pipe with no reader.

It looks as if the mail program could not be started (got the PATH right? Usually cron jobs have a very minimal PATH and you need to set it in your script with something like PATH=$(getconf PATH).)

Then cat pipes into a non-existing reader, and voila, there's your signal.

BTW, that's a useless use of cat, since mail -s subj recipient < /path/to/mail.txt would avoid an expensive fork and pipe.