Follow-up Comment #5, bug #54178 (project wget): Looking at the manual page for system(3) on my system:
RETURN VALUE The value returned is -1 on error (e.g., fork(2) failed), and the return status of the command otherwise. This latter return status is in the format specified in wait(2). Thus, the exit code of the command will be WEXITSTATUS(status). In case /bin/sh could not be executed, the exit status will be that of a command that does exit(127). Looking at the manual page for wait(2) on my system: WEXITSTATUS(status) returns the exit status of the child. This consists of the least significant 8 bits of the status argument that the child specified in a call to exit(3) or _exit(2) or as the argument for a return statement in main(). This macro should be employed only if WIFEXITED returned true. Blindly searching through the system *.h files, it appears that, effectively, #define WEXITSTATUS(status) (((status) & 0xff00) >> 8) This suggests that if you want to print the subprocess's exit status, you need to change the printf in wget2.c to: printf("wget result: %d\n", WEXITSTATUS(result)); The value of result as an integer isn't fixed by the specification of system(3), only the value of WEXITSTATUS(result). _______________________________________________________ Reply to this item at: <http://savannah.gnu.org/bugs/?54178> _______________________________________________ Message sent via Savannah https://savannah.gnu.org/