/*	@(#)system.c	1.2	*/
/*	3.0 SID #	1.4	*/
/*LINTLIBRARY*/
#include <signal.h>

extern int fork(), execve(), wait();
extern char **environ;
static char *argv[] = {"sh", "-c", 0, 0 };

int
system(s)
char	*s;
{
	int	status, pid, w;

	register int (*istat)(), (*qstat)();

	if((pid = fork()) == 0) {
		argv[2] = s;
		execve("/bin/sh",argv,environ);
/*		execl("/bin/sh", "sh", "-c", s, 0); */
		_exit(127);
	}
	istat = signal(SIGINT, SIG_IGN);
	qstat = signal(SIGQUIT, SIG_IGN);
	while((w = wait(&status)) != pid && w != -1)
		;
	signal(SIGINT, istat);
	signal(SIGQUIT, qstat);
	return((w == -1)? w: status);
}
