From 1fd98d7d880e470809cc3284ef04a03bf3490b02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Tue, 13 Oct 1998 14:52:33 +0000 Subject: [PATCH] Calls one or more of malloc(), warn(), err(), syslog(), execlp() or execvp() in the child branch of a vfork(). Changed to use fork() instead. Some of these (mv, find, apply, xargs) might benefit greatly from being rewritten to use vfork() properly. PR: Loosely related to bin/8252 Approved by: jkh and bde --- bin/mv/mv.c | 4 ++-- lib/libutil/pw_util.c | 6 +++--- usr.bin/apply/apply.c | 2 +- usr.bin/find/function.c | 4 ++-- usr.bin/newkey/update.c | 6 +----- usr.bin/time/time.c | 4 ++-- usr.bin/tn3270/sys_curses/system.c | 4 ++-- usr.bin/truss/setup.c | 8 ++++---- usr.bin/vacation/vacation.c | 4 ++-- usr.bin/xargs/xargs.c | 6 +++--- usr.bin/xinstall/xinstall.c | 4 ++-- usr.sbin/vipw/pw_util.c | 6 +++--- 12 files changed, 27 insertions(+), 31 deletions(-) diff --git a/bin/mv/mv.c b/bin/mv/mv.c index 27182857d8e7..b471bef4b1fa 100644 --- a/bin/mv/mv.c +++ b/bin/mv/mv.c @@ -45,7 +45,7 @@ static char const copyright[] = static char sccsid[] = "@(#)mv.c 8.2 (Berkeley) 4/2/94"; #endif static const char rcsid[] = - "$Id: mv.c,v 1.20 1998/06/09 03:39:38 imp Exp $"; + "$Id: mv.c,v 1.21 1998/06/28 21:00:04 bde Exp $"; #endif /* not lint */ #include @@ -308,7 +308,7 @@ copy(from, to) { int pid, status; - if ((pid = vfork()) == 0) { + if ((pid = fork()) == 0) { execl(_PATH_CP, "mv", "-PRp", from, to, NULL); warn("%s", _PATH_CP); _exit(1); diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c index b6f6719b08b8..d005d1610696 100644 --- a/lib/libutil/pw_util.c +++ b/lib/libutil/pw_util.c @@ -36,7 +36,7 @@ static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: pw_util.c,v 1.9 1997/10/27 07:53:19 charnier Exp $"; #endif /* not lint */ /* @@ -148,7 +148,7 @@ char *username; pid_t pid; (void)fflush(stderr); - if (!(pid = vfork())) { + if (!(pid = fork())) { if(!username) { warnx("rebuilding the database..."); execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL); @@ -180,7 +180,7 @@ pw_edit(notsetuid) else p = editor; - if (!(editpid = vfork())) { + if (!(editpid = fork())) { if (notsetuid) { (void)setgid(getgid()); (void)setuid(getuid()); diff --git a/usr.bin/apply/apply.c b/usr.bin/apply/apply.c index 78e90627e1f3..37a77b7d05c9 100644 --- a/usr.bin/apply/apply.c +++ b/usr.bin/apply/apply.c @@ -207,7 +207,7 @@ system(command) return(1); omask = sigblock(sigmask(SIGCHLD)); - switch(pid = vfork()) { + switch(pid = fork()) { case -1: /* error */ err(1, "fork"); case 0: /* child */ diff --git a/usr.bin/find/function.c b/usr.bin/find/function.c index 18102969bf62..1ffdd5236186 100644 --- a/usr.bin/find/function.c +++ b/usr.bin/find/function.c @@ -308,7 +308,7 @@ f_exec(plan, entry) /* make sure find output is interspersed correctly with subprocesses */ fflush(stdout); - switch (pid = vfork()) { + switch (pid = fork()) { case -1: err(1, "fork"); /* NOTREACHED */ @@ -414,7 +414,7 @@ f_execdir(plan, entry) fflush(stdout); fflush(stderr); - switch (pid = vfork()) { + switch (pid = fork()) { case -1: err(1, "fork"); /* NOTREACHED */ diff --git a/usr.bin/newkey/update.c b/usr.bin/newkey/update.c index 1c33bcbb3716..609977a593df 100644 --- a/usr.bin/newkey/update.c +++ b/usr.bin/newkey/update.c @@ -32,7 +32,7 @@ static char sccsid[] = "@(#)update.c 1.2 91/03/11 Copyr 1986 Sun Micro"; #endif static const char rcsid[] = - "$Id: update.c,v 1.2 1997/07/29 06:54:16 charnier Exp $"; + "$Id: update.c,v 1.3 1998/02/20 04:38:20 jb Exp $"; #endif /* @@ -167,11 +167,7 @@ _openchild(command, fto, ffrom) if (pipe(pdfrom) < 0) { goto error2; } -#ifdef VFORK - switch (pid = vfork()) { -#else switch (pid = fork()) { -#endif case -1: goto error3; diff --git a/usr.bin/time/time.c b/usr.bin/time/time.c index f74b6db8ae08..8d3d8a03c27d 100644 --- a/usr.bin/time/time.c +++ b/usr.bin/time/time.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)time.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: time.c,v 1.10 1998/07/28 10:08:16 des Exp $"; + "$Id: time.c,v 1.11 1998/08/24 10:16:59 cracauer Exp $"; #endif /* not lint */ #include @@ -106,7 +106,7 @@ main(argc, argv) } gettimeofday(&before, (struct timezone *)NULL); - switch(pid = vfork()) { + switch(pid = fork()) { case -1: /* error */ err(1, "time"); /* NOTREACHED */ diff --git a/usr.bin/tn3270/sys_curses/system.c b/usr.bin/tn3270/sys_curses/system.c index 67b31af3321a..68a8e5fc0486 100644 --- a/usr.bin/tn3270/sys_curses/system.c +++ b/usr.bin/tn3270/sys_curses/system.c @@ -722,9 +722,9 @@ char *argv[]; child_died(); /* Start up signal handler */ shell_active = 1; /* We are running down below */ - if (shell_pid = vfork()) { + if (shell_pid = fork()) { if (shell_pid == -1) { - perror("vfork"); + perror("fork"); (void) close(serversock); } else { state = UNCONNECTED; diff --git a/usr.bin/truss/setup.c b/usr.bin/truss/setup.c index 9d0abf2ea30c..fbef7e11a30b 100644 --- a/usr.bin/truss/setup.c +++ b/usr.bin/truss/setup.c @@ -31,7 +31,7 @@ #ifndef lint static const char rcsid[] = - "$Id$"; + "$Id: setup.c,v 1.7 1998/01/05 07:30:25 charnier Exp $"; #endif /* not lint */ /* @@ -56,7 +56,7 @@ static int evflags = 0; /* * setup_and_wait() is called to start a process. All it really does - * is vfork(), set itself up to stop on exec or exit, and then exec + * is fork(), set itself up to stop on exec or exit, and then exec * the given command. At that point, the child process stops, and * the parent can wake up and deal with it. */ @@ -69,9 +69,9 @@ setup_and_wait(char *command[]) { int pid; int flags; - pid = vfork(); + pid = fork(); if (pid == -1) { - err(1, "vfork failed"); + err(1, "fork failed"); } if (pid == 0) { /* Child */ int mask = S_EXEC | S_EXIT; diff --git a/usr.bin/vacation/vacation.c b/usr.bin/vacation/vacation.c index 6ea8c2884d77..8790163edeb6 100644 --- a/usr.bin/vacation/vacation.c +++ b/usr.bin/vacation/vacation.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "@(#)from: vacation.c 8.2 (Berkeley) 1/26/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: vacation.c,v 1.12 1997/11/03 07:51:05 charnier Exp $"; #endif /* not lint */ /* @@ -417,7 +417,7 @@ sendmessage(myname) syslog(LOG_ERR, "vacation: pipe: %s", strerror(errno)); exit(1); } - i = vfork(); + i = fork(); if (i < 0) { syslog(LOG_ERR, "vacation: fork: %s", strerror(errno)); exit(1); diff --git a/usr.bin/xargs/xargs.c b/usr.bin/xargs/xargs.c index d5cf5279970c..ec7eea33ae53 100644 --- a/usr.bin/xargs/xargs.c +++ b/usr.bin/xargs/xargs.c @@ -45,7 +45,7 @@ static const char copyright[] = static char sccsid[] = "@(#)xargs.c 8.1 (Berkeley) 6/6/93"; #endif static const char rcsid[] = - "$Id: xargs.c,v 1.5 1997/08/27 06:26:23 charnier Exp $"; + "$Id: xargs.c,v 1.6 1998/06/17 12:58:43 jkoshy Exp $"; #endif /* not lint */ #include @@ -287,9 +287,9 @@ run(argv) (void)fflush(stderr); } noinvoke = 0; - switch(pid = vfork()) { + switch(pid = fork()) { case -1: - err(1, "vfork"); + err(1, "fork"); case 0: execvp(argv[0], argv); warn("%s", argv[0]); diff --git a/usr.bin/xinstall/xinstall.c b/usr.bin/xinstall/xinstall.c index 61adb5d74e45..f6bc52c0ed46 100644 --- a/usr.bin/xinstall/xinstall.c +++ b/usr.bin/xinstall/xinstall.c @@ -42,7 +42,7 @@ static const char copyright[] = static char sccsid[] = "From: @(#)xinstall.c 8.1 (Berkeley) 7/21/93"; #endif static const char rcsid[] = - "$Id: xinstall.c,v 1.31 1998/01/20 13:52:32 bde Exp $"; + "$Id: xinstall.c,v 1.32 1998/06/02 12:00:07 peter Exp $"; #endif /* not lint */ /*- @@ -645,7 +645,7 @@ strip(to_name) { int serrno, status; - switch (vfork()) { + switch (fork()) { case -1: serrno = errno; (void)unlink(to_name); diff --git a/usr.sbin/vipw/pw_util.c b/usr.sbin/vipw/pw_util.c index b6f6719b08b8..d005d1610696 100644 --- a/usr.sbin/vipw/pw_util.c +++ b/usr.sbin/vipw/pw_util.c @@ -36,7 +36,7 @@ static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94"; #endif static const char rcsid[] = - "$Id$"; + "$Id: pw_util.c,v 1.9 1997/10/27 07:53:19 charnier Exp $"; #endif /* not lint */ /* @@ -148,7 +148,7 @@ char *username; pid_t pid; (void)fflush(stderr); - if (!(pid = vfork())) { + if (!(pid = fork())) { if(!username) { warnx("rebuilding the database..."); execl(_PATH_PWD_MKDB, "pwd_mkdb", "-p", tempname, NULL); @@ -180,7 +180,7 @@ pw_edit(notsetuid) else p = editor; - if (!(editpid = vfork())) { + if (!(editpid = fork())) { if (notsetuid) { (void)setgid(getgid()); (void)setuid(getuid());