From e2919519d77836132dca6140d8d23a24a7631a18 Mon Sep 17 00:00:00 2001 From: Roy Marples Date: Sat, 2 Feb 2008 00:38:06 +0000 Subject: [PATCH] Using syscall in a vfork is safe for sigaction and sigprogmask. --- src/librc/librc.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/librc/librc.c b/src/librc/librc.c index 1cd3eec5..669c27f5 100644 --- a/src/librc/librc.c +++ b/src/librc/librc.c @@ -32,6 +32,7 @@ const char librc_copyright[] = "Copyright (c) 2007-2008 Roy Marples"; #include "librc.h" +#include #include #define SOFTLEVEL RC_SVCDIR "/softlevel" @@ -606,18 +607,18 @@ static pid_t _exec_service (const char *service, const char *arg) sigfillset (&full); sigprocmask (SIG_SETMASK, &full, &old); - if ((pid = fork ()) == 0) { + if ((pid = vfork ()) == 0) { /* Restore default handlers */ - sigaction (SIGCHLD, &sa, NULL); - sigaction (SIGHUP, &sa, NULL); - sigaction (SIGINT, &sa, NULL); - sigaction (SIGQUIT, &sa, NULL); - sigaction (SIGTERM, &sa, NULL); - sigaction (SIGUSR1, &sa, NULL); - sigaction (SIGWINCH, &sa, NULL); + syscall (SYS_sigaction, SIGCHLD, &sa, NULL); + syscall (SYS_sigaction, SIGHUP, &sa, NULL); + syscall (SYS_sigaction, SIGINT, &sa, NULL); + syscall (SYS_sigaction, SIGQUIT, &sa, NULL); + syscall (SYS_sigaction, SIGTERM, &sa, NULL); + syscall (SYS_sigaction, SIGUSR1, &sa, NULL); + syscall (SYS_sigaction, SIGWINCH, &sa, NULL); /* Unmask signals */ - sigprocmask (SIG_SETMASK, &empty, NULL); + syscall (SYS_sigprocmask, SIG_SETMASK, &empty, NULL); /* Safe to run now */ execl (file, file, arg, (char *) NULL);