FreeBSD/usr.bin/apply/apply.c
/*
 * exec_shell --
 * 	Execute a shell command using passed use_shell and use_name
 * 	arguments.
 */
exec_shell
Execute a shell command using passed use_shell and use_name
arguments.
exec_shell Execute a shell command using passed use_shell and use_name arguments .
static int
exec_shell(const char *command, const char *use_shell, const char *use_name)
{
	pid_t pid;
	int omask, pstat;
	sig_t intsave, quitsave;
	if (!command)		
		return(1);
	omask = sigblock(sigmask(SIGCHLD));
	switch(pid = vfork()) {
	case -1:			
		err(1, "vfork");
	case 0:				
		(void)sigsetmask(omask);
		execl(use_shell, use_name, "-c", command, (char *)NULL);
		warn("%s", use_shell);
		_exit(1);
	}
	intsave = signal(SIGINT, SIG_IGN);
	quitsave = signal(SIGQUIT, SIG_IGN);
	pid = waitpid(pid, &pstat, 0);
	(void)sigsetmask(omask);
	(void)signal(SIGINT, intsave);
	(void)signal(SIGQUIT, quitsave);
	return(pid == -1 ? -1 : pstat);
}
static int exec_shell ( const char * command , const char * use_shell , const char * use_name ) { pid_t pid ; int omask , pstat ; sig_t intsave , quitsave ; if ( ! command ) return ( 1 ) ; omask = sigblock ( sigmask ( SIGCHLD ) ) ; switch ( pid = vfork ( ) ) { case -1 : err ( 1 , " " ) ; case 0 : ( void ) sigsetmask ( omask ) ; execl ( use_shell , use_name , " " , command , ( char * ) NULL ) ; warn ( " " , use_shell ) ; _exit ( 1 ) ; } intsave = signal ( SIGINT , SIG_IGN ) ; quitsave = signal ( SIGQUIT , SIG_IGN ) ; pid = waitpid ( pid , & pstat , 0 ) ; ( void ) sigsetmask ( omask ) ; ( void ) signal ( SIGINT , intsave ) ; ( void ) signal ( SIGQUIT , quitsave ) ; return ( pid == -1 ? -1 : pstat ) ; }
exec_shell
      Execute a shell command using passed use_shell and use_name
      arguments.
exec_shell Execute a shell command using passed use_shell and use_name arguments .
/* just checking... */ /* error */ /* child */