summaryrefslogtreecommitdiffstats
path: root/bin/mv
diff options
context:
space:
mode:
authordds <dds@FreeBSD.org>2007-12-17 09:02:42 +0000
committerdds <dds@FreeBSD.org>2007-12-17 09:02:42 +0000
commit03fb3792900dc40682ce7bf0fe337f2a9f4152aa (patch)
tree2f4f81b025d8552853976d526c945d5278b81de0 /bin/mv
parenta541ef6e7d7fe0d86656da7cb59e16001490c75d (diff)
downloadFreeBSD-src-03fb3792900dc40682ce7bf0fe337f2a9f4152aa.zip
FreeBSD-src-03fb3792900dc40682ce7bf0fe337f2a9f4152aa.tar.gz
Calling any function from vfork other than exec* and _exit yields
undefined behavior. Noted by: alfred
Diffstat (limited to 'bin/mv')
-rw-r--r--bin/mv/mv.c12
1 files changed, 9 insertions, 3 deletions
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;
OpenPOWER on IntegriCloud