From mboxrd@z Thu Jan 1 00:00:00 1970 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fee84,afc5a3ed94577019 X-Google-Attributes: gidfee84,public From: john@iastate.edu (John Hascall) Subject: Re: Return Status Codes for system() Function??? Date: 1997/05/24 Message-ID: <5m7ula$6ft$1@news.iastate.edu>#1/1 X-Deja-AN: 243695902 References: <3385E815.41C6@klab.caltech.edu> Organization: Iowa State University, Ames, Iowa USA Newsgroups: comp.unix.osf.osf1 James Bond wrote: }I'm stumped and hope this newsgroup can help me. }The return status from system() is 256!? What does this code mean? }Note errno is NOT set. errno is still zero. 256 is the int value }that is returned by system(). } }According to the man page, system() will return 0 if successful. }On error system() will return -1 and errno is set. Any other value }(such as 256!) is the same as wait(). Looking at the wait() man page, }it tells you to see the wait.h file. Looking at the wait.h file, }there is no mention of the 256 return status! What gives? The 'status' returned by wait is a whole bunch of bits wedged into an int. If you look at the definitions of WIFEXITED/WEXITSTATUS, etc in /usr/include/sys/wait.h you should find that FTP is returning a value of '1', that is the value looks like: +--------+-------+-------+-------+ | | |ret-val|status | +--------+-------+-------+-------+ (status == 0) => process exited with value 'retval' == 0177) => process stopped, signal# is in retval == other) => process killed by signal, status is signal# (if bit 0200 is set, core was dumped) }Looking at the other header files, there is no clue about the }return values of system(). Tried looking at the DEC website and }could not find a list of values. Actually, a list of the possible }values system() returns and their meanings would be very helpful. From "man system": |RETURN VALUES | | If the string parameter is NULL, the system() function returns 0 if it is | unable to access the command interpreter or a non-zero value if sh is | accessible. | | If the string parameter is not NULL, upon successful completion by sh, the | system() function returns the exit status of the shell process in the form | that wait(2) returns. Otherwise, the system() function returns a value of | -1 and sets errno to indicate the error. | | Exit status 127 indicates that the shell could not be executed. | | Note that the exit status should only be interpreted using the macros | described in wait(2) and defined in the sys/wait.h header file. John -- John Hascall, Software Engr. Shut up, be happy. The conveniences you ISU Computation Center demanded are now mandatory. -Jello Biafra mailto:john@iastate.edu http://www.cc.iastate.edu/staff/systems/john/welcome.html <-- the usual crud