add system(3) for spawning the editor - this is handy when EDITOR is set to

something like 'editor arg1 arg2 ...'
This commit is contained in:
jdolecek 2000-05-27 19:01:13 +00:00
parent 902ae34ae6
commit 2d6c6df05e
1 changed files with 13 additions and 6 deletions

View File

@ -1,4 +1,4 @@
/* $NetBSD: disklabel.c,v 1.82 2000/05/25 21:23:37 thorpej Exp $ */ /* $NetBSD: disklabel.c,v 1.83 2000/05/27 19:01:13 jdolecek Exp $ */
/* /*
* Copyright (c) 1987, 1993 * Copyright (c) 1987, 1993
@ -47,7 +47,7 @@ __COPYRIGHT("@(#) Copyright (c) 1987, 1993\n\
static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95"; static char sccsid[] = "@(#)disklabel.c 8.4 (Berkeley) 5/4/95";
/* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */ /* from static char sccsid[] = "@(#)disklabel.c 1.2 (Symmetric) 11/28/85"; */
#else #else
__RCSID("$NetBSD: disklabel.c,v 1.82 2000/05/25 21:23:37 thorpej Exp $"); __RCSID("$NetBSD: disklabel.c,v 1.83 2000/05/27 19:01:13 jdolecek Exp $");
#endif #endif
#endif /* not lint */ #endif /* not lint */
@ -1330,16 +1330,23 @@ editit()
sleep(1); sleep(1);
} }
if (pid == 0) { if (pid == 0) {
char *ed; const char *ed;
char *buf;
int retval;
sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0); sigprocmask(SIG_SETMASK, &osigset, (sigset_t *)0);
setgid(getgid()); setgid(getgid());
setuid(getuid()); setuid(getuid());
if ((ed = getenv("EDITOR")) == (char *)0) if ((ed = getenv("EDITOR")) == (char *)0)
ed = DEFEDITOR; ed = DEFEDITOR;
execlp(ed, ed, tmpfil, 0); /*
perror(ed); * Use system(3) in case someone's editor is "editor arg1 arg2".
exit(1); */
asprintf(&buf, "%s %s", ed, tmpfil);
retval = system(buf);
if (retval == -1)
perror(ed);
exit(retval);
} }
while ((xpid = wait(&stat)) >= 0) while ((xpid = wait(&stat)) >= 0)
if (xpid == pid) if (xpid == pid)