xref: /csrg-svn/games/trek/shell.c (revision 34205)
121295Sdist /*
221295Sdist  * Copyright (c) 1980 Regents of the University of California.
3*34205Sbostic  * All rights reserved.
4*34205Sbostic  *
5*34205Sbostic  * Redistribution and use in source and binary forms are permitted
6*34205Sbostic  * provided that this notice is preserved and that due credit is given
7*34205Sbostic  * to the University of California at Berkeley. The name of the University
8*34205Sbostic  * may not be used to endorse or promote products derived from this
9*34205Sbostic  * software without specific prior written permission. This software
10*34205Sbostic  * is provided ``as is'' without express or implied warranty.
1121295Sdist  */
1221295Sdist 
1311696Smckusick #ifndef lint
14*34205Sbostic static char sccsid[] = "@(#)shell.c	5.2 (Berkeley) 05/05/88";
15*34205Sbostic #endif /* not lint */
1611696Smckusick 
1711696Smckusick /*
1811696Smckusick **  CALL THE SHELL
1911696Smckusick */
2011696Smckusick 
2111696Smckusick shell()
2211696Smckusick {
2311696Smckusick 	int		i;
2411696Smckusick 	register int	pid;
2511696Smckusick 	register int	sav2, sav3;
2611696Smckusick 
2711696Smckusick 	if (!(pid = fork()))
2811696Smckusick 	{
2911696Smckusick 		setuid(getuid());
3011696Smckusick 		nice(0);
3112345Slayer 		execl("/bin/csh", "-", 0);
3212345Slayer 		syserr("cannot execute /bin/csh");
3311696Smckusick 	}
3411696Smckusick 	sav2 = signal(2, 1);
3511696Smckusick 	sav3 = signal(3, 1);
3611696Smckusick 	while (wait(&i) != pid) ;
3711696Smckusick 	signal(2, sav2);
3811696Smckusick 	signal(3, sav3);
3911696Smckusick }
40