summaryrefslogtreecommitdiffstats
path: root/usr.sbin/sysinstall
diff options
context:
space:
mode:
authorjkh <jkh@FreeBSD.org>1995-05-18 02:42:33 +0000
committerjkh <jkh@FreeBSD.org>1995-05-18 02:42:33 +0000
commit2831e6ec6177d558463cf22f90a0a04d21b4934b (patch)
tree38d812f59039a9564a1bf3408206578e0bbbf7c7 /usr.sbin/sysinstall
parenta6430b5b82980a2bac470aebc14110f550aea79f (diff)
downloadFreeBSD-src-2831e6ec6177d558463cf22f90a0a04d21b4934b.zip
FreeBSD-src-2831e6ec6177d558463cf22f90a0a04d21b4934b.tar.gz
Use my own version of system() everywhere - it knows where to find the
shell!
Diffstat (limited to 'usr.sbin/sysinstall')
-rw-r--r--usr.sbin/sysinstall/command.c4
-rw-r--r--usr.sbin/sysinstall/system.c25
2 files changed, 25 insertions, 4 deletions
diff --git a/usr.sbin/sysinstall/command.c b/usr.sbin/sysinstall/command.c
index 03989cc..ee7ce78 100644
--- a/usr.sbin/sysinstall/command.c
+++ b/usr.sbin/sysinstall/command.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: command.c,v 1.3 1995/05/16 02:52:56 jkh Exp $
+ * $Id: command.c,v 1.4 1995/05/16 11:37:07 jkh Exp $
*
* Copyright (c) 1995
* Jordan Hubbard. All rights reserved.
@@ -166,7 +166,7 @@ command_execute(void)
if (commandStack[i]->cmds[j].type == CMD_SHELL) {
msgNotify("Executing command: %s",
commandStack[i]->cmds[j].ptr);
- ret = system((char *)commandStack[i]->cmds[j].ptr);
+ ret = vsystem((char *)commandStack[i]->cmds[j].ptr);
msgDebug("Command `%s' returns status %d\n",
commandStack[i]->cmds[j].ptr, ret);
}
diff --git a/usr.sbin/sysinstall/system.c b/usr.sbin/sysinstall/system.c
index 90e1ed3..cb620fe 100644
--- a/usr.sbin/sysinstall/system.c
+++ b/usr.sbin/sysinstall/system.c
@@ -4,7 +4,7 @@
* This is probably the last program in the `sysinstall' line - the next
* generation being essentially a complete rewrite.
*
- * $Id: system.c,v 1.11 1995/05/16 11:37:26 jkh Exp $
+ * $Id: system.c,v 1.12 1995/05/17 16:16:10 jkh Exp $
*
* Jordan Hubbard
*
@@ -265,6 +265,10 @@ int
vsystem(char *fmt, ...)
{
va_list args;
+ union wait pstat;
+ pid_t pid;
+ int omask;
+ sig_t intsave, quitsave;
char *cmd;
int i;
@@ -273,8 +277,25 @@ vsystem(char *fmt, ...)
va_start(args, fmt);
vsnprintf(cmd, FILENAME_MAX, fmt, args);
va_end(args);
+ omask = sigblock(sigmask(SIGCHLD));
msgNotify("Executing command: %s", cmd);
- i = system(cmd);
+ switch(pid = vfork()) {
+ case -1: /* error */
+ (void)sigsetmask(omask);
+ i = 127;
+
+ case 0: /* child */
+ (void)sigsetmask(omask);
+ execl("/stand/sh", "sh", "-c", cmd, (char *)NULL);
+ i = 127;
+ }
+ intsave = signal(SIGINT, SIG_IGN);
+ quitsave = signal(SIGQUIT, SIG_IGN);
+ pid = waitpid(pid, (int *)&pstat, 0);
+ (void)sigsetmask(omask);
+ (void)signal(SIGINT, intsave);
+ (void)signal(SIGQUIT, quitsave);
+ i = (pid == -1) ? -1 : pstat.w_status;
msgDebug("Command `%s' returns status of %d\n", cmd, i);
free(cmd);
return i;
OpenPOWER on IntegriCloud