[NTLUG:Discuss] OT C system call question
Chris Cox
cjcox at acm.org
Mon Jan 30 17:22:14 CST 2006
Fred James wrote:
> All
> In C there is "system"
> (SYNOPSIS
> #include <stdlib.h>
>
> int system (const char *string);
> )
>
> What I think I have found is that if the command inside the ( ... ) is a
> shell script and it returns a numeric value (as in: exit $i), the C
> program will see it as that number multiplied by 256 (i.e., 0 is 0, 1
> becomes 256, 2 becomes 512, etc.). [these test were run on an SGI IRIX
> 6.4 machine]
>
> Can anyone confirm or deny that, or offer any enlightenment, please?
> Thank you in advance for any help you may be able to offer.
The return code is shifted 8 bits (so shift >>8). ... but that's the same as
divide by 256.
More information about the Discuss
mailing list