[NTLUG:Discuss] Re: OT C system call question

Graham Wilson graham at mknod.org
Mon Jan 30 17:11:42 CST 2006


On Mon, Jan 30, 2006 at 04:51:08PM -0600, Fred James wrote:
> 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]

Yes, this is known behavior. See the system(3) man page for more
details. You can get the exit status by using the WEXITSTATUS macro,
defined in the the same header file I believe.

-- 
gram




More information about the Discuss mailing list