Calling any function from vfork other than exec* and _exit yields

undefined behavior.

Noted by:	alfred
This commit is contained in:
Diomidis Spinellis 2007-12-17 09:02:42 +00:00
parent 8090c9f504
commit 3db8241bb4

View File

@ -419,8 +419,7 @@ copy(char *from, char *to)
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 @@ copy(char *from, char *to)
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;