From 03fb3792900dc40682ce7bf0fe337f2a9f4152aa Mon Sep 17 00:00:00 2001 From: dds Date: Mon, 17 Dec 2007 09:02:42 +0000 Subject: Calling any function from vfork other than exec* and _exit yields undefined behavior. Noted by: alfred --- bin/mv/mv.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'bin/mv') diff --git a/bin/mv/mv.c b/bin/mv/mv.c index 2e97293..ba72968 100644 --- a/bin/mv/mv.c +++ b/bin/mv/mv.c @@ -419,8 +419,7 @@ done: if (!(pid = vfork())) { execl(_PATH_RM, "mv", "-rf", "--", cleanup[i], (char *)NULL); - warn("%s %s", _PATH_RM, cleanup[i]); - _exit(1); + _exit(EX_OSERR); } if (waitpid(pid, &status, 0) == -1) { warn("%s %s: waitpid", _PATH_RM, cleanup[i]); @@ -433,7 +432,14 @@ done: rval = 1; continue; } - if (WEXITSTATUS(status)) { + switch (WEXITSTATUS(status)) { + case 0: + break; + case EX_OSERR: + warnx("Failed to exec %s %s", _PATH_RM, cleanup[i]); + rval = 1; + continue; + default: warnx("%s %s: terminated with %d (non-zero) status", _PATH_RM, cleanup[i], WEXITSTATUS(status)); rval = 1; -- cgit v1.1