daemon caching weird exit status from a shell script



Hi folks:

I'm developing a daemon written in C which will control some program
execution (something like init, but simpler),
and I'm getting something strange. I'm using fork() and execv() to
execute a bash script, for instance, and
the parent process is calling waitpid() to collect script exit status.
When the script ends with "exit 1" bash
instruction, waitpid() collects 256 as exit status, when it end with
"exit 2", 512 is collected. Seems that
the exit status from a bash script is seen as a more significant byte
within C daemon code and the
first byte is zeroed. Why? Is that right? What I done was to shift 8
bits right the exit status...

thanks for any information.
regards
Lucas Brasilino

* GNU bash, version 3.00.16(1)-release (i386-redhat-linux-gnu)
* gcc version 4.0.2 20051125 (Red Hat 4.0.2-8)
* glibc-2.3.6-3
* Fedora Core 4

.



Relevant Pages

  • Re: daemon caching weird exit status from a shell script
    ... execution, ... the parent process is calling waitpid() to collect script exit status. ... the exit status from a bash script is seen as a more significant byte ...
    (comp.os.linux.development.apps)
  • Re: [SLE] closing a window running a bash script
    ... > John R. Sowden wrote: ... >> How do I close the window on a bash script I wrote. ... I put exit at the end, ... echo This program requires Root Authority. ...
    (SuSE)
  • Re: [SLE] closing a window running a bash script
    ... > How do I close the window on a bash script I wrote. ... > to mount an encrypted partition in case I didn't enter the password when I ... I put exit at the end, ... Actually, the shell isn't closing, because the command you're running ...
    (SuSE)
  • Re: logical OR - bash ..problems
    ... I am running a bash script that loops until a file becomes ... created/present. ... It loops waiting on 1 to 3 files, ... the script does not exit as expected. ...
    (comp.unix.shell)
  • Re: Bad habits of GOTO-using programmers
    ... The fact that it contains only the word EXIT confirms its function. ...     perform section-a ... The results of the execution of overlapping PERFORM statements are ...     The exit to main is destroyed by the second perform of a-x. ...
    (comp.lang.cobol)