aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDiomidis Spinellis <dds@FreeBSD.org>2007-12-17 09:02:42 +0000
committerDiomidis Spinellis <dds@FreeBSD.org>2007-12-17 09:02:42 +0000
commit3db8241bb44f806e8c034094b992d799a8607b36 (patch)
tree2f4f81b025d8552853976d526c945d5278b81de0
parent8090c9f504c0c19831713ab2392d0993a5fc5b36 (diff)
downloadsrc-3db8241bb44f806e8c034094b992d799a8607b36.tar.gz
src-3db8241bb44f806e8c034094b992d799a8607b36.zip
Calling any function from vfork other than exec* and _exit yields
undefined behavior. Noted by: alfred
Notes
Notes: svn path=/head/; revision=174709
-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 2e972931c68b..ba72968f7272 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;