Skip to content

Commit e1b14e6

Browse files
committed
Further error checking, all possibilities should now be accounted for
1 parent 4192f95 commit e1b14e6

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

src/util.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,11 +117,17 @@ execute(const char *cmd_line, int quiet)
117117
debug(LOG_DEBUG, "Waiting for PID %d to exit", pid);
118118
rc = waitpid(pid, &status, 0);
119119
debug(LOG_DEBUG, "Process PID %d exited", rc);
120+
121+
if (-1 == rc) {
122+
debug(LOG_ERR, "waitpid() failed (%s)", strerror(errno));
123+
return 1; /* waitpid failed. */
124+
}
120125

121126
if (WIFEXITED(status)) {
122127
return (WEXITSTATUS(status));
123128
} else {
124129
/* If we get here, child did not exit cleanly. Will return non-zero exit code to caller*/
130+
debug(LOG_DEBUG, "Child may have been killed.");
125131
return 1;
126132
}
127133
}

0 commit comments

Comments
 (0)