summaryrefslogtreecommitdiff
path: root/src/lib/libc/stdlib/system.c
diff options
context:
space:
mode:
authormillert <>2001-09-04 23:35:58 +0000
committermillert <>2001-09-04 23:35:58 +0000
commit5e24150fd2b66c78de49cbce05efef82adcf4d7d (patch)
tree8304b9c2cba586b245ee8b14ec3c91bab60ea298 /src/lib/libc/stdlib/system.c
parent311001e1e488adf9abd558a81b3c0bdee6f5b75b (diff)
downloadopenbsd-5e24150fd2b66c78de49cbce05efef82adcf4d7d.tar.gz
openbsd-5e24150fd2b66c78de49cbce05efef82adcf4d7d.tar.bz2
openbsd-5e24150fd2b66c78de49cbce05efef82adcf4d7d.zip
Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.
Diffstat (limited to 'src/lib/libc/stdlib/system.c')
-rw-r--r--src/lib/libc/stdlib/system.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/lib/libc/stdlib/system.c b/src/lib/libc/stdlib/system.c
index 3e1b047393..dadf3fe841 100644
--- a/src/lib/libc/stdlib/system.c
+++ b/src/lib/libc/stdlib/system.c
@@ -32,7 +32,7 @@
32 */ 32 */
33 33
34#if defined(LIBC_SCCS) && !defined(lint) 34#if defined(LIBC_SCCS) && !defined(lint)
35static char *rcsid = "$OpenBSD: system.c,v 1.3 1996/09/15 09:31:52 tholo Exp $"; 35static char *rcsid = "$OpenBSD: system.c,v 1.4 2001/09/04 23:35:58 millert Exp $";
36#endif /* LIBC_SCCS and not lint */ 36#endif /* LIBC_SCCS and not lint */
37 37
38#include <sys/types.h> 38#include <sys/types.h>
@@ -50,7 +50,7 @@ system(command)
50{ 50{
51 pid_t pid; 51 pid_t pid;
52 sig_t intsave, quitsave; 52 sig_t intsave, quitsave;
53 int omask; 53 sigset_t mask, omask;
54 int pstat; 54 int pstat;
55 char *argp[] = {"sh", "-c", NULL, NULL}; 55 char *argp[] = {"sh", "-c", NULL, NULL};
56 56
@@ -59,13 +59,15 @@ system(command)
59 59
60 argp[2] = (char *)command; 60 argp[2] = (char *)command;
61 61
62 omask = sigblock(sigmask(SIGCHLD)); 62 sigemptyset(&mask);
63 sigaddset(&mask, SIGCHLD);
64 sigprocmask(SIG_BLOCK, &mask, &omask);
63 switch(pid = vfork()) { 65 switch(pid = vfork()) {
64 case -1: /* error */ 66 case -1: /* error */
65 (void)sigsetmask(omask); 67 sigprocmask(SIG_SETMASK, &omask, NULL);
66 return(-1); 68 return(-1);
67 case 0: /* child */ 69 case 0: /* child */
68 (void)sigsetmask(omask); 70 sigprocmask(SIG_SETMASK, &omask, NULL);
69 execve(_PATH_BSHELL, argp, environ); 71 execve(_PATH_BSHELL, argp, environ);
70 _exit(127); 72 _exit(127);
71 } 73 }
@@ -73,7 +75,7 @@ system(command)
73 intsave = signal(SIGINT, SIG_IGN); 75 intsave = signal(SIGINT, SIG_IGN);
74 quitsave = signal(SIGQUIT, SIG_IGN); 76 quitsave = signal(SIGQUIT, SIG_IGN);
75 pid = waitpid(pid, (int *)&pstat, 0); 77 pid = waitpid(pid, (int *)&pstat, 0);
76 (void)sigsetmask(omask); 78 sigprocmask(SIG_SETMASK, &omask, NULL);
77 (void)signal(SIGINT, intsave); 79 (void)signal(SIGINT, intsave);
78 (void)signal(SIGQUIT, quitsave); 80 (void)signal(SIGQUIT, quitsave);
79 return(pid == -1 ? -1 : pstat); 81 return(pid == -1 ? -1 : pstat);