mirror of
https://git.FreeBSD.org/src.git
synced 2024-12-21 11:13:30 +00:00
aa7d974a35
Removed a dialog_clear() which somebody aimlessly had slammed into TellEm() in absence of any understanding of the structure of this program. :-( Skip through stage0 for now. Make write_bootblocks write the disklabel using the kernel-call, and forget about the boot-blocks for now. This is wrong, but I havn't found the real problem yet. I will continue work on this problem. Added a Debug-feature. There is a printf' like Debug() now which sends its output to ttyv1 (Alt-F2), and all "discarded output" from sub-processes end up there too. Made TellEm() put it's messages there also, so that we can see where what happens. Set the PATH for the shell we shouldn't start at the end :-) set "npartitions" after the disklabel-editor returns, so that we actually can edit all the 8 parts of the label.
80 lines
1.7 KiB
C
80 lines
1.7 KiB
C
/*
|
|
* ----------------------------------------------------------------------------
|
|
* "THE BEER-WARE LICENSE" (Revision 42):
|
|
* <phk@login.dkuug.dk> wrote this file. As long as you retain this notice you
|
|
* can do whatever you want with this stuff. If we meet some day, and you think
|
|
* this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
|
|
* ----------------------------------------------------------------------------
|
|
*
|
|
* $Id: exec.c,v 1.4 1994/10/26 05:40:59 phk Exp $
|
|
*
|
|
*/
|
|
|
|
#include <stdlib.h>
|
|
#include <stdio.h>
|
|
#include <stdarg.h>
|
|
#include <unistd.h>
|
|
#include <string.h>
|
|
#include <dialog.h>
|
|
#include <errno.h>
|
|
#include <fcntl.h>
|
|
|
|
#include <sys/stat.h>
|
|
#include <sys/types.h>
|
|
#include <sys/wait.h>
|
|
#include <sys/param.h>
|
|
#include <sys/mount.h>
|
|
|
|
#include "sysinstall.h"
|
|
|
|
int
|
|
exec(int magic, char *cmd, char *args, ...)
|
|
{
|
|
int pid, w, status;
|
|
char *argv[EXEC_MAXARG];
|
|
int arg = 0;
|
|
va_list ap;
|
|
struct stat dummy;
|
|
|
|
if (stat(cmd, &dummy) == -1) {
|
|
sprintf(errmsg, "Executable %s does not exist\n", cmd);
|
|
return(-1);
|
|
}
|
|
|
|
va_start(ap, args);
|
|
argv[arg++] = (char *)args;
|
|
do {
|
|
if (arg >= EXEC_MAXARG)
|
|
Fatal("Too many arguments");
|
|
} while ((argv[arg++] = va_arg(ap, char *)));
|
|
va_end(ap);
|
|
|
|
if ((pid = fork()) == 0) {
|
|
switch (magic) {
|
|
case 0:
|
|
close(0); dup(debug_fd);
|
|
close(1); dup(debug_fd);
|
|
close(2); dup(debug_fd);
|
|
close(debug_fd);
|
|
break;
|
|
case 1:
|
|
close(2); dup(debug_fd);
|
|
close(debug_fd);
|
|
break;
|
|
case 2:
|
|
close(debug_fd);
|
|
default:
|
|
break;
|
|
}
|
|
execv(cmd, argv);
|
|
exit(1);
|
|
}
|
|
|
|
while ((w = wait(&status)) != pid && w != -1)
|
|
;
|
|
|
|
if (w == -1)
|
|
Fatal("Child process %s terminated abnormally\n", cmd);
|
|
return(status);
|
|
}
|