apply.c (54157) | apply.c (60706) |
---|---|
1/*- 2 * Copyright (c) 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Jan-Simon Pendry. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38#if 0 39static const char sccsid[] = "@(#)apply.c 8.4 (Berkeley) 4/4/94"; 40#endif 41static const char rcsid[] = | 1/*- 2 * Copyright (c) 1994 3 * The Regents of the University of California. All rights reserved. 4 * 5 * This code is derived from software contributed to Berkeley by 6 * Jan-Simon Pendry. 7 * 8 * Redistribution and use in source and binary forms, with or without --- 25 unchanged lines hidden (view full) --- 34 * SUCH DAMAGE. 35 */ 36 37#ifndef lint 38#if 0 39static const char sccsid[] = "@(#)apply.c 8.4 (Berkeley) 4/4/94"; 40#endif 41static const char rcsid[] = |
42 "$FreeBSD: head/usr.bin/apply/apply.c 54157 1999-12-05 19:53:37Z charnier $"; | 42 "$FreeBSD: head/usr.bin/apply/apply.c 60706 2000-05-19 09:42:53Z kris $"; |
43#endif /* not lint */ 44 45#include <sys/wait.h> 46 47#include <ctype.h> 48#include <err.h> 49#include <paths.h> 50#include <signal.h> --- 154 unchanged lines hidden (view full) --- 205 name = shell; 206 else 207 ++name; 208 } 209 if (!command) /* just checking... */ 210 return(1); 211 212 omask = sigblock(sigmask(SIGCHLD)); | 43#endif /* not lint */ 44 45#include <sys/wait.h> 46 47#include <ctype.h> 48#include <err.h> 49#include <paths.h> 50#include <signal.h> --- 154 unchanged lines hidden (view full) --- 205 name = shell; 206 else 207 ++name; 208 } 209 if (!command) /* just checking... */ 210 return(1); 211 212 omask = sigblock(sigmask(SIGCHLD)); |
213 switch(pid = fork()) { | 213 switch(pid = vfork()) { |
214 case -1: /* error */ | 214 case -1: /* error */ |
215 err(1, "fork"); | 215 err(1, "vfork"); |
216 case 0: /* child */ 217 (void)sigsetmask(omask); 218 execl(shell, name, "-c", command, NULL); | 216 case 0: /* child */ 217 (void)sigsetmask(omask); 218 execl(shell, name, "-c", command, NULL); |
219 err(1, "%s", shell); | 219 warn("%s", shell); 220 _exit(1); |
220 } 221 intsave = signal(SIGINT, SIG_IGN); 222 quitsave = signal(SIGQUIT, SIG_IGN); 223 pid = waitpid(pid, &pstat, 0); 224 (void)sigsetmask(omask); 225 (void)signal(SIGINT, intsave); 226 (void)signal(SIGQUIT, quitsave); 227 return(pid == -1 ? -1 : pstat); 228} 229 230void 231usage() 232{ 233 234 (void)fprintf(stderr, 235 "usage: apply [-a magic] [-d] [-0123456789] command arguments ...\n"); 236 exit(1); 237} | 221 } 222 intsave = signal(SIGINT, SIG_IGN); 223 quitsave = signal(SIGQUIT, SIG_IGN); 224 pid = waitpid(pid, &pstat, 0); 225 (void)sigsetmask(omask); 226 (void)signal(SIGINT, intsave); 227 (void)signal(SIGQUIT, quitsave); 228 return(pid == -1 ? -1 : pstat); 229} 230 231void 232usage() 233{ 234 235 (void)fprintf(stderr, 236 "usage: apply [-a magic] [-d] [-0123456789] command arguments ...\n"); 237 exit(1); 238} |