aboutsummaryrefslogtreecommitdiff
path: root/src/com_start.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/com_start.c')
-rw-r--r--src/com_start.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/com_start.c b/src/com_start.c
index 5744e39..3a9dffc 100644
--- a/src/com_start.c
+++ b/src/com_start.c
@@ -34,27 +34,31 @@ report_exec_error(int rc, char const *program)
typedef void (*SIGHANDLER)(int);
void
sigchld(int sig)
{
}
int
timedwaitpid(pid_t pid, int *status)
{
struct timeval now, stoptime, ttw;
int rc = -1;
- SIGHANDLER oldsig;
+ struct sigaction act, oldact;
+
+ act.sa_handler = sigchld;
+ act.sa_flags = 0;
+ sigemptyset(&act.sa_mask);
+ sigaction(SIGCHLD, &act, &oldact);
- oldsig = signal(SIGCHLD, sigchld);
gettimeofday(&stoptime, NULL);
stoptime.tv_sec += genrc_timeout;
while (1) {
pid_t p;
p = waitpid(pid, status, WNOHANG);
if (p == pid) {
rc = 0;
break;
}
if (p < 0 && errno != EINTR) {
system_error(errno, "waitpid");
@@ -64,25 +68,25 @@ timedwaitpid(pid_t pid, int *status)
gettimeofday(&now, NULL);
if (timercmp(&now, &stoptime, >=))
break;
timersub(&stoptime, &now, &ttw);
if (select(0, NULL, NULL, NULL, &ttw) < 0) {
if (errno != EINTR) {
system_error(errno, "select");
break;
}
}
}
- signal(SIGCHLD, oldsig);
+ sigaction(SIGCHLD, &oldact, NULL);
if (rc) {
kill(pid, SIGKILL);
}
return rc;
}
int
com_start(void)
{
pid_t pid;
int status;
PIDLIST pids;

Return to:

Send suggestions and report system problems to the System administrator.