summaryrefslogtreecommitdiffstats
path: root/release/sysinstall/system.c
diff options
context:
space:
mode:
authorphk <phk@FreeBSD.org>1995-05-20 19:12:13 +0000
committerphk <phk@FreeBSD.org>1995-05-20 19:12:13 +0000
commit8874835086bd5b4560192f88191aa557a445702b (patch)
tree6a0a6d72ea95ef176dd4fad790e966dec9a8849e /release/sysinstall/system.c
parent7ee584e87b77288741d4f89ccd93c8cdfd0e6c87 (diff)
downloadFreeBSD-src-8874835086bd5b4560192f88191aa557a445702b.zip
FreeBSD-src-8874835086bd5b4560192f88191aa557a445702b.tar.gz
Change vsystem to know that the shell is crunched in.
Sanitize a couple of messages.
Diffstat (limited to 'release/sysinstall/system.c')
-rw-r--r--release/sysinstall/system.c58
1 files changed, 55 insertions, 3 deletions
diff --git a/release/sysinstall/system.c b/release/sysinstall/system.c
index 28efd39..b25888f 100644
--- a/release/sysinstall/system.c
+++ b/release/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.21 1995/05/20 08:31:43 jkh Exp $
+ * $Id: system.c,v 1.22 1995/05/20 13:24:35 jkh Exp $
*
* Jordan Hubbard
*
@@ -276,10 +276,62 @@ systemChangeScreenmap(const u_char newmap[])
dialog_clear();
}
}
+/* Execute a command that is crunched into the same binary */
+int
+vsystem(char *fmt, ...)
+{
+ va_list args;
+ union wait pstat;
+ pid_t pid;
+ int omask;
+ sig_t intsave, quitsave;
+ char *cmd,*argv[100];
+ int i;
+
+ cmd = (char *)malloc(FILENAME_MAX);
+ cmd[0] = '\0';
+ va_start(args, fmt);
+ vsnprintf(cmd, FILENAME_MAX, fmt, args);
+ va_end(args);
+ omask = sigblock(sigmask(SIGCHLD));
+ msgDebug("Executing command `%s'\n", cmd);
+ switch(pid = fork()) {
+ case -1: /* error */
+ (void)sigsetmask(omask);
+ i = 127;
+
+ case 0: /* child */
+ (void)sigsetmask(omask);
+ if (DebugFD != -1) {
+ if (OnVTY)
+ msgInfo("Command output is on debugging screen - type ALT-F2 to see it");
+ dup2(DebugFD, 0);
+ dup2(DebugFD, 1);
+ dup2(DebugFD, 2);
+ }
+ i = 0;
+ argv[i++] = "crunch";
+ argv[i++] = "sh";
+ argv[i++] = "-c";
+ argv[i++] = cmd;
+ argv[i] = 0;
+ exit(crunched_main(i,argv));
+ }
+ 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;
+}
/* Execute a system command, with varargs */
int
-vsystem(char *fmt, ...)
+ssystem(char *fmt, ...)
{
va_list args;
union wait pstat;
@@ -295,7 +347,7 @@ vsystem(char *fmt, ...)
vsnprintf(cmd, FILENAME_MAX, fmt, args);
va_end(args);
omask = sigblock(sigmask(SIGCHLD));
- msgDebug("Executing command `%s'", cmd);
+ msgDebug("Executing command `%s'\n", cmd);
switch(pid = vfork()) {
case -1: /* error */
(void)sigsetmask(omask);
OpenPOWER on IntegriCloud