Browse Source

Replace the deprecated BSD sigsetmask/sigblock/sigpause functions with their POSIX counterparts.

OPENBSD_3_0
millert 23 years ago
parent
commit
734e2e00f3
1 changed files with 8 additions and 6 deletions
  1. +8
    -6
      src/lib/libc/stdlib/system.c

+ 8
- 6
src/lib/libc/stdlib/system.c View File

@ -32,7 +32,7 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
static char *rcsid = "$OpenBSD: system.c,v 1.3 1996/09/15 09:31:52 tholo Exp $";
static char *rcsid = "$OpenBSD: system.c,v 1.4 2001/09/04 23:35:58 millert Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/types.h>
@ -50,7 +50,7 @@ system(command)
{
pid_t pid;
sig_t intsave, quitsave;
int omask;
sigset_t mask, omask;
int pstat;
char *argp[] = {"sh", "-c", NULL, NULL};
@ -59,13 +59,15 @@ system(command)
argp[2] = (char *)command;
omask = sigblock(sigmask(SIGCHLD));
sigemptyset(&mask);
sigaddset(&mask, SIGCHLD);
sigprocmask(SIG_BLOCK, &mask, &omask);
switch(pid = vfork()) {
case -1: /* error */
(void)sigsetmask(omask);
sigprocmask(SIG_SETMASK, &omask, NULL);
return(-1);
case 0: /* child */
(void)sigsetmask(omask);
sigprocmask(SIG_SETMASK, &omask, NULL);
execve(_PATH_BSHELL, argp, environ);
_exit(127);
}
@ -73,7 +75,7 @@ system(command)
intsave = signal(SIGINT, SIG_IGN);
quitsave = signal(SIGQUIT, SIG_IGN);
pid = waitpid(pid, (int *)&pstat, 0);
(void)sigsetmask(omask);
sigprocmask(SIG_SETMASK, &omask, NULL);
(void)signal(SIGINT, intsave);
(void)signal(SIGQUIT, quitsave);
return(pid == -1 ? -1 : pstat);


Loading…
Cancel
Save