missing information in man 3 system

Erich Dollansky erichsfreebsdlist at alogt.com
Mon Feb 11 05:04:49 UTC 2013


Hi,

man 3 system says:

RETURN VALUES

The system() function returns the exit status of the shell as returned
by waitpid(2), or -1 if an error occurred when invoking fork(2) or
waitpid(2). A return value of 127 means the execution of the shell
failed.

It seems to me that one part is missing here. I made two small test
programs:

Program 1 in error.c

int main (void)
{
   return 0x1;
}

Program 2 in show result:

int main (void)
{
   printf ("Return code: %i\n", system ("error"));
   return 0
}

This results in

Return code: 256

being displayed.

system () returns the result from 'error.c' in the result but shifted
by 8 bits to the left.

I could not find this behaviour in the FreeBSD documentation.

So, is this the intended behaviour of system ()?

Should the documentation be uptdated?

Or did I simply miss something?

Erich


More information about the freebsd-doc mailing list