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>
This commit is contained in:
parent
37a182e2b2
commit
4da8edd59e
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/head/; revision=40538
@ -36,7 +36,7 @@
|
|||||||
static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
|
static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -45,6 +45,7 @@ static const char rcsid[] =
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/errno.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -185,16 +186,18 @@ pw_edit(notsetuid)
|
|||||||
(void)setgid(getgid());
|
(void)setgid(getgid());
|
||||||
(void)setuid(getuid());
|
(void)setuid(getuid());
|
||||||
}
|
}
|
||||||
|
errno = 0;
|
||||||
execlp(editor, p, tempname, NULL);
|
execlp(editor, p, tempname, NULL);
|
||||||
_exit(1);
|
_exit(errno);
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
|
editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
|
||||||
|
errno = WEXITSTATUS(pstat);
|
||||||
if (editpid == -1)
|
if (editpid == -1)
|
||||||
pw_error(editor, 1, 1);
|
pw_error(editor, 1, 1);
|
||||||
else if (WIFSTOPPED(pstat))
|
else if (WIFSTOPPED(pstat))
|
||||||
raise(WSTOPSIG(pstat));
|
raise(WSTOPSIG(pstat));
|
||||||
else if (WIFEXITED(pstat) && WEXITSTATUS(pstat) == 0)
|
else if (WIFEXITED(pstat) && errno == 0)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
pw_error(editor, 1, 1);
|
pw_error(editor, 1, 1);
|
||||||
|
@ -36,7 +36,7 @@
|
|||||||
static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
|
static const char sccsid[] = "@(#)pw_util.c 8.3 (Berkeley) 4/2/94";
|
||||||
#endif
|
#endif
|
||||||
static const char rcsid[] =
|
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 */
|
#endif /* not lint */
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -45,6 +45,7 @@ static const char rcsid[] =
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#include <sys/errno.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include <sys/resource.h>
|
#include <sys/resource.h>
|
||||||
#include <sys/stat.h>
|
#include <sys/stat.h>
|
||||||
@ -185,16 +186,18 @@ pw_edit(notsetuid)
|
|||||||
(void)setgid(getgid());
|
(void)setgid(getgid());
|
||||||
(void)setuid(getuid());
|
(void)setuid(getuid());
|
||||||
}
|
}
|
||||||
|
errno = 0;
|
||||||
execlp(editor, p, tempname, NULL);
|
execlp(editor, p, tempname, NULL);
|
||||||
_exit(1);
|
_exit(errno);
|
||||||
}
|
}
|
||||||
for (;;) {
|
for (;;) {
|
||||||
editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
|
editpid = waitpid(editpid, (int *)&pstat, WUNTRACED);
|
||||||
|
errno = WEXITSTATUS(pstat);
|
||||||
if (editpid == -1)
|
if (editpid == -1)
|
||||||
pw_error(editor, 1, 1);
|
pw_error(editor, 1, 1);
|
||||||
else if (WIFSTOPPED(pstat))
|
else if (WIFSTOPPED(pstat))
|
||||||
raise(WSTOPSIG(pstat));
|
raise(WSTOPSIG(pstat));
|
||||||
else if (WIFEXITED(pstat) && WEXITSTATUS(pstat) == 0)
|
else if (WIFEXITED(pstat) && errno == 0)
|
||||||
break;
|
break;
|
||||||
else
|
else
|
||||||
pw_error(editor, 1, 1);
|
pw_error(editor, 1, 1);
|
||||||
|
Loading…
Reference in New Issue
Block a user