date and time created 80/12/21 16:51:01 by wnj
[unix-history] / usr / src / lib / libc / stdlib / system.c
CommitLineData
a59df51f
BJ
1/* @(#)system.c 4.1 (Berkeley) %G% */
2#include <signal.h>
3
4system(s)
5char *s;
6{
7 int status, pid, w;
8 register int (*istat)(), (*qstat)();
9
10 if ((pid = vfork()) == 0) {
11 execl("/bin/sh", "sh", "-c", s, 0);
12 _exit(127);
13 }
14 istat = signal(SIGINT, SIG_IGN);
15 qstat = signal(SIGQUIT, SIG_IGN);
16 while ((w = wait(&status)) != pid && w != -1)
17 ;
18 if (w == -1)
19 status = -1;
20 signal(SIGINT, istat);
21 signal(SIGQUIT, qstat);
22 return(status);
23}