summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek R. Price <derek@ximbiot.com>2006-04-25 20:58:26 +0000
committerDerek R. Price <derek@ximbiot.com>2006-04-25 20:58:26 +0000
commit6d8d4e520be656b646a6f5cf7ebebfc31c178022 (patch)
tree99edbed416b6e9dba5124a90985c54586451902f
parent528b229aa8932bc5e1fdf7b0c7cdc5b7713b1edf (diff)
downloadgnulib-6d8d4e520be656b646a6f5cf7ebebfc31c178022.tar.gz
* 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 a signal. * lib/csharpcomp.c, lib/execute.c, lib/javacomp.c: Update all callers.
-rw-r--r--lib/ChangeLog8
-rw-r--r--lib/csharpcomp.c5
-rw-r--r--lib/execute.c2
-rw-r--r--lib/javacomp.c2
-rw-r--r--lib/wait-process.c4
-rw-r--r--lib/wait-process.h6
6 files changed, 21 insertions, 6 deletions
diff --git a/lib/ChangeLog b/lib/ChangeLog
index 2bd50a790b..72675902ee 100644
--- a/lib/ChangeLog
+++ b/lib/ChangeLog
@@ -1,3 +1,11 @@
+2006-04-25 Derek Price <derek@ximbiot.com>
+
+ * wait-process.h (wait_subprocess): Accept a new exitsignal argument.
+ * 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
+ a signal.
+ * csharpcomp.c, execute.c, javacomp.c: Update all callers.
+
2006-04-25 Paul Eggert <eggert@cs.ucla.edu>
* getdate.y (get_date): When adding relative date, start with the
diff --git a/lib/csharpcomp.c b/lib/csharpcomp.c
index 2344a99622..e157db67ce 100644
--- a/lib/csharpcomp.c
+++ b/lib/csharpcomp.c
@@ -295,7 +295,8 @@ compile_csharp_using_mono (const char * const *sources,
fclose (fp);
/* Remove zombie process from process list, and retrieve exit status. */
- exitstatus = wait_subprocess (child, "mcs", false, false, true, true);
+ exitstatus = wait_subprocess (child, "mcs", NULL, false, false, true,
+ true);
for (i = 0; i < sources_count; i++)
if (argv[argc - sources_count + i] != sources[i])
@@ -366,7 +367,7 @@ compile_csharp_using_sscli (const char * const *sources,
/* Remove zombie process from process list, and retrieve exit
status. */
exitstatus =
- wait_subprocess (child, "csc", false, true, true, false);
+ wait_subprocess (child, "csc", NULL, false, true, true, false);
if (exitstatus != 0)
csc_present = false;
}
diff --git a/lib/execute.c b/lib/execute.c
index df6b1eaa84..add7163417 100644
--- a/lib/execute.c
+++ b/lib/execute.c
@@ -308,7 +308,7 @@ execute (const char *progname,
unblock_fatal_signals ();
}
- return wait_subprocess (child, progname, ignore_sigpipe, null_stderr,
+ return wait_subprocess (child, progname, NULL, ignore_sigpipe, null_stderr,
slave_process, exit_on_error);
#endif
diff --git a/lib/javacomp.c b/lib/javacomp.c
index 04013e96e8..e4d60a11f8 100644
--- a/lib/javacomp.c
+++ b/lib/javacomp.c
@@ -240,7 +240,7 @@ compile_java_class (const char * const *java_sources,
/* Remove zombie process from process list, and retrieve exit
status. */
exitstatus =
- wait_subprocess (child, "gcj", false, true, true, false);
+ wait_subprocess (child, "gcj", NULL, false, true, true, false);
if (exitstatus != 0)
gcj_present = false;
}
diff --git a/lib/wait-process.c b/lib/wait-process.c
index 221a39c10e..0fd6f26676 100644
--- a/lib/wait-process.c
+++ b/lib/wait-process.c
@@ -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 *progname,
WAIT_T status;
*(int *) &status = 0;
+ if (exitsignal) *exitsignal = 0;
for (;;)
{
int result = waitpid (child, &status, 0);
@@ -394,6 +395,7 @@ wait_subprocess (pid_t child, const char *progname,
error (exit_on_error ? EXIT_FAILURE : 0, 0,
_("%s subprocess got fatal signal %d"),
progname, (int) WTERMSIG (status));
+ if (exitsignal) *exitsignal = WTERMSIG (status);
return 127;
}
if (WEXITSTATUS (status) == 127)
diff --git a/lib/wait-process.h b/lib/wait-process.h
index 9cdce30478..f1f7776740 100644
--- a/lib/wait-process.h
+++ b/lib/wait-process.h
@@ -34,11 +34,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
@@ -50,6 +53,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);