aboutsummaryrefslogtreecommitdiff
path: root/helper
diff options
context:
space:
mode:
authorCarl Wallen <carl.wallen@nokia.com>2015-10-30 15:16:06 +0200
committerMaxim Uvarov <maxim.uvarov@linaro.org>2015-11-05 10:34:22 +0300
commit8bc76ef7d5f9caf691ac23e584aa618cb39e0f7f (patch)
treece69aa1011eab734ba0a060ae1cd9c4e6f3ced4d /helper
parent3d0dafc1dc72dab028db1b06f183339e7d578d5b (diff)
helper: linux: examine the cause for child process termination
odph_linux_process_wait_n(): This patch helps catch child abnormal termination by breaking out of the wait()-loop on error. Examine what caused a forked child process to terminate. Do not wait() for other children if the termination status indicates error in the child, return -1 instead. Children that are not waited for will be terminated by the SIGTERM signal once the parent exits (requested by the prctl(PR_SET_PDEATHSIG, SIGTERM) call after child fork) even if the parent does not perform any explicit clean-up actions. Signed-off-by: Carl Wallen <carl.wallen@nokia.com> Reviewed-by: Petri Savolainen <petri.savolainen@nokia.com> Signed-off-by: Maxim Uvarov <maxim.uvarov@linaro.org>
Diffstat (limited to 'helper')
-rw-r--r--helper/linux.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/helper/linux.c b/helper/linux.c
index 3d5da184e..6e7020692 100644
--- a/helper/linux.c
+++ b/helper/linux.c
@@ -224,7 +224,21 @@ int odph_linux_process_wait_n(odph_linux_process_t *proc_tbl, int num)
}
if (j == num) {
- ODPH_ERR("Bad pid\n");
+ ODPH_ERR("Bad pid:%d\n", (int)pid);
+ return -1;
+ }
+
+ /* Examine the child process' termination status */
+ if (WIFEXITED(status) && WEXITSTATUS(status) != EXIT_SUCCESS) {
+ ODPH_ERR("Child exit status:%d (pid:%d)\n",
+ WEXITSTATUS(status), (int)pid);
+ return -1;
+ }
+ if (WIFSIGNALED(status)) {
+ int signo = WTERMSIG(status);
+
+ ODPH_ERR("Child term signo:%d - %s (pid:%d)\n",
+ signo, strsignal(signo), (int)pid);
return -1;
}
}