From 4da8edd59ed91c145d89d24c82d14cd66c32fd97 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Dag-Erling=20Sm=C3=B8rgrav?= Date: Tue, 20 Oct 1998 11:34:11 +0000 Subject: [PATCH] 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 --- lib/libutil/pw_util.c | 9 ++++++--- usr.sbin/vipw/pw_util.c | 9 ++++++--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/lib/libutil/pw_util.c b/lib/libutil/pw_util.c index d005d1610696..8a74fc01f881 100644 --- a/lib/libutil/pw_util.c +++ b/lib/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 +#include #include #include #include @@ -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); diff --git a/usr.sbin/vipw/pw_util.c b/usr.sbin/vipw/pw_util.c index d005d1610696..8a74fc01f881 100644 --- a/usr.sbin/vipw/pw_util.c +++ b/usr.sbin/vipw/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 +#include #include #include #include @@ -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);