xref: /csrg-svn/games/trek/shell.c (revision 34789)
121295Sdist /*
221295Sdist  * Copyright (c) 1980 Regents of the University of California.
334205Sbostic  * All rights reserved.
434205Sbostic  *
534205Sbostic  * Redistribution and use in source and binary forms are permitted
6*34789Sbostic  * provided that the above copyright notice and this paragraph are
7*34789Sbostic  * duplicated in all such forms and that any documentation,
8*34789Sbostic  * advertising materials, and other materials related to such
9*34789Sbostic  * distribution and use acknowledge that the software was developed
10*34789Sbostic  * by the University of California, Berkeley.  The name of the
11*34789Sbostic  * University may not be used to endorse or promote products derived
12*34789Sbostic  * from this software without specific prior written permission.
13*34789Sbostic  * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
14*34789Sbostic  * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
15*34789Sbostic  * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
1621295Sdist  */
1721295Sdist 
1811696Smckusick #ifndef lint
19*34789Sbostic static char sccsid[] = "@(#)shell.c	5.3 (Berkeley) 06/18/88";
2034205Sbostic #endif /* not lint */
2111696Smckusick 
2211696Smckusick /*
2311696Smckusick **  CALL THE SHELL
2411696Smckusick */
2511696Smckusick 
shell()2611696Smckusick shell()
2711696Smckusick {
2811696Smckusick 	int		i;
2911696Smckusick 	register int	pid;
3011696Smckusick 	register int	sav2, sav3;
3111696Smckusick 
3211696Smckusick 	if (!(pid = fork()))
3311696Smckusick 	{
3411696Smckusick 		setuid(getuid());
3511696Smckusick 		nice(0);
3612345Slayer 		execl("/bin/csh", "-", 0);
3712345Slayer 		syserr("cannot execute /bin/csh");
3811696Smckusick 	}
3911696Smckusick 	sav2 = signal(2, 1);
4011696Smckusick 	sav3 = signal(3, 1);
4111696Smckusick 	while (wait(&i) != pid) ;
4211696Smckusick 	signal(2, sav2);
4311696Smckusick 	signal(3, sav3);
4411696Smckusick }
45