SCCS-vsn: usr.bin/find/find.c 4.13
-static char *sccsid = "@(#)find.c 4.12 (Berkeley) %G%";
+static char *sccsid = "@(#)find.c 4.13 (Berkeley) %G%";
#endif
#include <stdio.h>
#endif
#include <stdio.h>
register char *na;
static char *nargv[50];
static ccode;
register char *na;
static char *nargv[50];
static ccode;
- register int w, pid, (*sigint)(), (*sigquit)(), cantexec;
+ register int w, pid, omask;
ccode = np = 0;
while (na=Argv[com++]) {
ccode = np = 0;
while (na=Argv[com++]) {
}
nargv[np] = 0;
if (np==0) return(9);
}
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");
switch (pid = vfork()) {
case -1:
perror("find: Can't fork");
case 0:
chdir(Home);
execvp(nargv[0], nargv, np);
case 0:
chdir(Home);
execvp(nargv[0], nargv, np);
- cantexec = 1; /* XXX */
- _exit(1);
+ 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);
- sigint = signal(SIGINT, SIG_IGN);
- sigquit = signal(SIGQUIT, SIG_IGN);
+ omask = sigblock(sigmask(SIGINT)|sigmask(SIGQUIT));
while ((w = wait(&ccode)) != pid && w != -1)
;
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]);
+ (void) sigsetmask(omask);
+ if ((ccode & 0177) == SIGUSR1)
return (ccode != 0 ? 0 : 1);
}
}
return (ccode != 0 ? 0 : 1);
}
}