Re: GNULIB wait-process module.
Derek Price <[email protected]> Tue, 08 Mar 2005 14:52:23 -0500
| Newsgroups | gmane.comp.lib.gnulib.bugs,gmane.comp.version-control.cvs.bugs |
|---|---|
| Organization | Get CVS Support from Ximbiot <http://ximbiot.com>! |
| Message-ID | <[email protected]> |
-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Any further thoughts on this patch? | 2005-03-04 Derek R. Price <[email protected]> | | * lib/wait-process.h (wait_subprocess): Accept a new exitsignal | argument. * lib/wait-process.c (wait_subprocess): Always set | *exitsignal to 0 when present and set it to the offending signal | when the child exits due to one. | | | Regards, | | Derek | | | ---------------------------------------------------------------------- | | | Index: lib/wait-process.c | =================================================================== | RCS file: /cvsroot/gnulib/gnulib/lib/wait-process.c,v retrieving | revision 1.3 diff -u -p -r1.3 wait-process.c --- lib/wait-process.c | 20 Jan 2004 16:47:31 -0000 1.3 +++ lib/wait-process.c 4 Mar 2005 | 16:18:13 -0000 @@ -251,7 +251,7 @@ unregister_slave_subprocess | (pid_t child If it didn't terminate correctly, exit if | exit_on_error is true, otherwise return 127. */ int | -wait_subprocess (pid_t child, const char *progname, | +wait_subprocess (pid_t child, const char *progname, int | *exitsignal, bool ignore_sigpipe, bool null_stderr, bool | slave_process, bool exit_on_error) { @@ -345,6 +345,7 @@ | wait_subprocess (pid_t child, const char WAIT_T status; | | *(int *) &status = 0; + if (exitsignal) *exitsignal = 0; for (;;) | { int result = waitpid (child, &status, 0); @@ -390,6 +391,7 @@ | wait_subprocess (pid_t child, const char if (WTERMSIG (status) == | SIGPIPE && ignore_sigpipe) return 0; # endif + if (exitsignal) | *exitsignal = WTERMSIG (status); if (exit_on_error || !null_stderr) | error (exit_on_error ? EXIT_FAILURE : 0, 0, _("%s subprocess got | fatal signal %d"), Index: lib/wait-process.h | =================================================================== | RCS file: /cvsroot/gnulib/gnulib/lib/wait-process.h,v retrieving | revision 1.2 diff -u -p -r1.2 wait-process.h --- lib/wait-process.h | 20 Jan 2004 16:47:31 -0000 1.2 +++ lib/wait-process.h 4 Mar 2005 | 16:18:13 -0000 @@ -36,11 +36,14 @@ extern "C" { | | /* Wait for a subprocess to finish. Return its exit code. If it | didn't terminate correctly, exit if exit_on_error is true, | otherwise - return 127. + return 127 and set exitsignal if the | child terminated because of a signal. Arguments: - child is the pid | of the subprocess. - progname is the name of the program executed | by the subprocess, used for error messages. + - exitsignal is an | optional pointer to an int to hold the signal number of + any | signal that caused the child to exit. It will be set to zero if | this + function exits with an error not caused by the child | catching a signal. - If ignore_sigpipe is true, consider a | subprocess termination due to SIGPIPE as equivalent to a success. | This is suitable for processes whose only purpose is to write to | standard output. This flag can be safely set @@ -52,6 +55,7 @@ | extern "C" { - If exit_on_error is true, any error will cause the | main process to exit with an error status. */ extern int | wait_subprocess (pid_t child, const char *progname, + int | *exitsignal, bool ignore_sigpipe, bool null_stderr, bool | slave_process, bool exit_on_error); -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.0 (Cygwin) Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org iD8DBQFCLgJ3LD1OTBfyMaQRAmFLAJ92TMkcy8zKktKMl1SbdC7f2/DeuACg5mbU SJQ75ER8kCDgUBSMFKgQUdw= =1Ocs -----END PGP SIGNATURE-----