This is the mail archive of the guile@cygnus.com mailing list for the guile project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
> Which one is the right value for -1? Both! And neither! > guile> (system "guile -c \"(exit -1)\"") > 65280 > > szi@olivia:/home/szi$ make -f make-test > guile -c "(exit -1)" > make: *** [all] Error 255 There are a couple of problems here. Under unix at least, the argument to exit muct be an integer value between 0 and 255. Anything else results in undefined behaviour. You should never exit with -1. What's happening in your second example is that the -1 (binary 11111111111111111111111111111111) is being truncated to an 8 bit value, 11111111, or 255. This result is encoded and returned to make, which decodes the value and presents 255. The same thing is happening in your first example, except that guile isn't decoding the result for you. If you were to call system() from C, then you would use the WEXITSTATUS macro to decode the result. On your machine, this would shift the result to the right by 8 bits. 65280 >> 8 == 255. You need to do this yourself in Guile. Unfortunately, this isn't portable. As long as Guile is providing 'system', it should provide some support for extracting the results properly. Hmmm.. now that I think about it, 'system' isn't very schemey, is it? I think we should trash it in favour of something that actually returns a decoded exit code, and does some kind of appropriate throw otherwise. AG -- Anthony Green Cygnus Solutions Sunnyvale, California