Commit e70ea6d9 authored by Ronny Wichers Schreur's avatar Ronny Wichers Schreur 🏢
Browse files

Fixed wait_for_child handling.

parent 16df162b
......@@ -37,21 +37,34 @@ static void log (char *format, ...)
static int wait_for_child (pid_t pid, char *child_name, int *status_p)
{
int result, stat;
pid_t return_pid;
(void) waitpid (pid, &stat, 0);
return_pid = waitpid (pid, &stat, 0);
if (return_pid == -1)
/* child exited before call to waitpid */
return 0;
if (return_pid != pid)
{
fprintf (stderr, "wait_for_child: unexpected pid result (%d)\n",
(int) return_pid);
exit (1);
}
*status_p=stat;
result = WEXITSTATUS (stat);
if (WIFSIGNALED(stat))
log ("%s signaled (%d, %d)\n",child_name,
WTERMSIG(stat), stat&255);
if (WIFSIGNALED(stat) != 0)
log ("%s signaled (%d)\n",child_name,
(int) WTERMSIG(stat));
else if (WIFEXITED (stat))
log ("%s exited normally (%d, %d)\n", child_name,
WEXITSTATUS(stat),stat&255);
log ("%s exited normally (%d)\n", child_name,
(int) WEXITSTATUS(stat));
else
log ("%s exited abnormally (%d, %d)\n",child_name,
result, stat&255);
*status_p=stat;
log ("%s exited abnormally (%d)\n",child_name, (int) result);
return result;
return result;
}
static void error (char *error_string)
......@@ -81,7 +94,7 @@ int stop_caching_compiler (void)
fflush (compiler_commands);
r=wait_for_child (pid, "Clean compiler",&status);
if (status!=0) {
if (r!=0) {
log ("r=%d status=%xd\n", r, status);
error ("clm: error after stopping compiler");
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment