default:
{
int st;
- waitpid(pid, &st, 0);
- cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
- DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d]",
- cxt->helper, cxt->helper_status));
- cxt->helper_exec_status = rc = 0;
+ if (waitpid(pid, &st, 0) == (pid_t) -1) {
+ cxt->helper_status = -1;
+ rc = -errno;
+ } else {
+ cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
+ cxt->helper_exec_status = rc = 0;
+ }
+ DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d, rc=%d%s]",
+ cxt->helper,
+ cxt->helper_status, rc,
+ rc ? " waitpid failed" : ""));
break;
}
default:
{
int st;
- waitpid(pid, &st, 0);
- cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
- DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d]",
- cxt->helper, cxt->helper_status));
- cxt->helper_exec_status = rc = 0;
+ if (waitpid(pid, &st, 0) == (pid_t) -1) {
+ cxt->helper_status = -1;
+ rc = -errno;
+ } else {
+ cxt->helper_status = WIFEXITED(st) ? WEXITSTATUS(st) : -1;
+ cxt->helper_exec_status = rc = 0;
+ }
+ DBG(CXT, ul_debugobj(cxt, "%s executed [status=%d, rc=%d%s]",
+ cxt->helper,
+ cxt->helper_status, rc,
+ rc ? " waitpid failed" : ""));
break;
}