xref: /csrg-svn/lib/libc/stdlib/system.c (revision 26603)
1 #if defined(LIBC_SCCS) && !defined(lint)
2 static char sccsid[] = "@(#)system.c	5.2 (Berkeley) 03/09/86";
3 #endif LIBC_SCCS and not lint
4 
5 #include	<signal.h>
6 
7 system(s)
8 char *s;
9 {
10 	int status, pid, w;
11 	register int (*istat)(), (*qstat)();
12 
13 	if ((pid = vfork()) == 0) {
14 		execl("/bin/sh", "sh", "-c", s, 0);
15 		_exit(127);
16 	}
17 	istat = signal(SIGINT, SIG_IGN);
18 	qstat = signal(SIGQUIT, SIG_IGN);
19 	while ((w = wait(&status)) != pid && w != -1)
20 		;
21 	if (w == -1)
22 		status = -1;
23 	signal(SIGINT, istat);
24 	signal(SIGQUIT, qstat);
25 	return(status);
26 }
27