summaryrefslogtreecommitdiffstats
path: root/libutil
diff options
context:
space:
mode:
authorDag-Erling Smørgrav <des@FreeBSD.org>1998-10-20 11:34:11 +0000
committerDag-Erling Smørgrav <des@FreeBSD.org>1998-10-20 11:34:11 +0000
commit43db2f01d12e3d613fdc8747ed4a16080f11ba79 (patch)
tree97b5a37c6f267a7df4eced9b37c7c7ca7f1ceeab /libutil
parent176caa2877a07af869b5c469a57147a23c3f27b2 (diff)
downloadpw-darwin-43db2f01d12e3d613fdc8747ed4a16080f11ba79.tar.gz
pw-darwin-43db2f01d12e3d613fdc8747ed4a16080f11ba79.tar.zst
pw-darwin-43db2f01d12e3d613fdc8747ed4a16080f11ba79.zip
Since vfork() was changed to fork(), we have to pass errno back from the
child to the parent somehow. PR: 8353 Submitted by: Andrew J. Korty <ajk@purdue.edu>
Diffstat (limited to 'libutil')
-rw-r--r--libutil/pw_util.c9
1 files changed, 6 insertions, 3 deletions
diff --git a/libutil/pw_util.c b/libutil/pw_util.c
index d005d16..8a74fc0 100644
--- a/libutil/pw_util.c
+++ b/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: pw_util.c,v 1.9 1997/10/27 07:53:19 charnier Exp $";
+ "$Id: pw_util.c,v 1.10 1998/10/13 14:52:33 des Exp $";
#endif /* not lint */
/*
@@ -45,6 +45,7 @@ static const char rcsid[] =
*/
#include <sys/param.h>
+#include <sys/errno.h>
#include <sys/time.h>
#include <sys/resource.h>
#include <sys/stat.h>
@@ -185,16 +186,18 @@ pw_edit(notsetuid)
(void)setgid(getgid());
(void)setuid(getuid());
}
+ errno = 0;
execlp(editor, p, tempname, NULL);
- _exit(1);
+ _exit(errno);
}
for (;;) {
editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
+ errno = WEXITSTATUS(pstat);
if (editpid == -1)
pw_error(editor, 1, 1);
else if (WIFSTOPPED(pstat))
raise(WSTOPSIG(pstat));
- else if (WIFEXITED(pstat) && WEXITSTATUS(pstat) == 0)
+ else if (WIFEXITED(pstat) && errno == 0)
break;
else
pw_error(editor, 1, 1);