File:  [CSRG BSD Unix] / 43BSDTahoe / usr.bin / find / test / diff-c.new
Revision 1.1.1.1 (vendor branch): download - view: text, annotated - select for diffs
Tue Apr 24 16:12:58 2018 UTC (8 years, 1 month ago) by root
Branches: MAIN, BSD
CVS tags: HEAD, BSD43tahoe
BSD 4.3tahoe

*** find.c.orig	Fri Aug 16 18:55:48 1985
--- find.c	Fri Aug 16 18:57:09 1985
***************
*** 551,557 ****
  	register char *na;
  	static char *nargv[50];
  	static ccode;
! 	register int w, pid, (*sigint)(), (*sigquit)(), cantexec;
  
  	ccode = np = 0;
  	while (na=Argv[com++]) {
--- 551,557 ----
  	register char *na;
  	static char *nargv[50];
  	static ccode;
! 	register int w, pid, omask;
  
  	ccode = np = 0;
  	while (na=Argv[com++]) {
***************
*** 562,572 ****
  	}
  	nargv[np] = 0;
  	if (np==0) return(9);
- 	/*
- 	 * This is a kludge, but the alternative is to reserve
- 	 * some exit code (e.g. 0xff) to denote inability to exec.
- 	 */
- 	cantexec = 0;
  	switch (pid = vfork()) {
  	case -1:
  		perror("find: Can't fork");
--- 562,567 ----
***************
*** 576,597 ****
  	case 0:
  		chdir(Home);
  		execvp(nargv[0], nargv, np);
! 		cantexec = 1;	/* XXX */
! 		_exit(1);
  		break;
  
  	default:
! 		sigint = signal(SIGINT, SIG_IGN);
! 		sigquit = signal(SIGQUIT, SIG_IGN);
  		while ((w = wait(&ccode)) != pid && w != -1)
  			;
! 		signal(SIGQUIT, sigquit);
! 		signal(SIGINT, sigint);
! 		if (cantexec) {	/* XXX */
! 			fprintf(stderr, "find: Can't execute ");
! 			perror(nargv[0]);
  			exit(1);
- 		}
  		return (ccode != 0 ? 0 : 1);
  	}
  }
--- 571,592 ----
  	case 0:
  		chdir(Home);
  		execvp(nargv[0], nargv, np);
! 		write(2, "find: Can't execute ", 20);
! 		_perror(nargv[0]);
! 		/*
! 		 * Kill ourselves; our exit status will be a suicide
! 		 * note indicating we couldn't do the "exec".
! 		 */
! 		kill(getpid(), SIGUSR1);
  		break;
  
  	default:
! 		omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT));
  		while ((w = wait(&ccode)) != pid && w != -1)
  			;
! 		(void) sigsetmask(omask);
! 		if ((ccode & 0177) == SIGUSR1)
  			exit(1);
  		return (ccode != 0 ? 0 : 1);
  	}
  }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.