conmon: Return the exit status code
waitpid fills its second argument with a value that contains the process exit code in the 8 least significant bits. Instead of returning the complete value and then convert it from ocid, return the exit status directly by using WEXITSTATUS from conmon. Signed-off-by: Samuel Ortiz <sameo@linux.intel.com>
This commit is contained in:
parent
61e60bfe47
commit
9a4a1092fe
3 changed files with 5 additions and 8 deletions
|
@ -303,10 +303,12 @@ int main(int argc, char *argv[])
|
|||
|
||||
/* Wait for the container process and record its exit code */
|
||||
while ((pid = waitpid(-1, &status, 0)) > 0) {
|
||||
printf("PID %d exited\n", pid);
|
||||
int exit_status = WEXITSTATUS(status);
|
||||
|
||||
printf("PID %d exited with status %d\n", pid, exit_status);
|
||||
if (pid == cpid) {
|
||||
_cleanup_free_ char *status_str = NULL;
|
||||
ret = asprintf(&status_str, "%d", status);
|
||||
ret = asprintf(&status_str, "%d", exit_status);
|
||||
if (ret < 0) {
|
||||
pexit("Failed to allocate memory for status");
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue