vt: send interrupt on exit, open logfile OCEXEC, run host after environment got exported, send rest of arguments to host
This commit is contained in:
parent
d4cc35f387
commit
db729cbb50
|
@ -131,24 +131,18 @@ Rune* onscreenp(int, int);
|
||||||
int
|
int
|
||||||
start_host(void)
|
start_host(void)
|
||||||
{
|
{
|
||||||
int fd;
|
|
||||||
|
|
||||||
switch((hostpid = rfork(RFPROC|RFNAMEG|RFFDG|RFNOTEG))) {
|
switch((hostpid = rfork(RFPROC|RFNAMEG|RFFDG|RFNOTEG))) {
|
||||||
case 0:
|
case 0:
|
||||||
fd = open("/dev/cons", OREAD);
|
close(0);
|
||||||
dup(fd,0);
|
open("/dev/cons", OREAD);
|
||||||
if(fd != 0)
|
close(1);
|
||||||
close(fd);
|
open("/dev/cons", OWRITE);
|
||||||
fd = open("/dev/cons", OWRITE);
|
dup(1, 2);
|
||||||
dup(fd,1);
|
|
||||||
dup(fd,2);
|
|
||||||
if(fd != 1 && fd !=2)
|
|
||||||
close(fd);
|
|
||||||
execl("/bin/rc","rcX",nil);
|
execl("/bin/rc","rcX",nil);
|
||||||
fprint(2,"failed to start up rc\n");
|
fprint(2, "failed to start up rc: %r\n");
|
||||||
_exits("rc");
|
_exits("rc");
|
||||||
case -1:
|
case -1:
|
||||||
fprint(2,"rc startup: fork error\n");
|
fprint(2,"rc startup: fork: %r\n");
|
||||||
_exits("rc_fork");
|
_exits("rc_fork");
|
||||||
}
|
}
|
||||||
return open("/mnt/cons/data", ORDWR);
|
return open("/mnt/cons/data", ORDWR);
|
||||||
|
@ -192,6 +186,7 @@ hostreader(void*)
|
||||||
static void
|
static void
|
||||||
shutdown(void)
|
shutdown(void)
|
||||||
{
|
{
|
||||||
|
send_interrupt();
|
||||||
postnote(PNGROUP, getpid(), "exit");
|
postnote(PNGROUP, getpid(), "exit");
|
||||||
threadexitsall(nil);
|
threadexitsall(nil);
|
||||||
}
|
}
|
||||||
|
@ -208,7 +203,7 @@ threadmain(int argc, char **argv)
|
||||||
void
|
void
|
||||||
usage(void)
|
usage(void)
|
||||||
{
|
{
|
||||||
fprint(2, "usage: %s [-2abcrx] [-f font] [-l logfile]\n", argv0);
|
fprint(2, "usage: %s [-2abcrx] [-f font] [-l logfile] [cmd...]\n", argv0);
|
||||||
exits("usage");
|
exits("usage");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -244,7 +239,7 @@ initialize(int argc, char **argv)
|
||||||
break;
|
break;
|
||||||
case 'l':
|
case 'l':
|
||||||
p = EARGF(usage());
|
p = EARGF(usage());
|
||||||
logfd = create(p, OWRITE, 0666);
|
logfd = create(p, OWRITE|OCEXEC, 0666);
|
||||||
if(logfd < 0)
|
if(logfd < 0)
|
||||||
sysfatal("could not create log file: %s: %r", p);
|
sysfatal("could not create log file: %s: %r", p);
|
||||||
break;
|
break;
|
||||||
|
@ -269,9 +264,6 @@ initialize(int argc, char **argv)
|
||||||
if((cs = consctl()) == nil)
|
if((cs = consctl()) == nil)
|
||||||
sysfatal("consctl failed: %r");
|
sysfatal("consctl failed: %r");
|
||||||
cs->raw = rflag;
|
cs->raw = rflag;
|
||||||
hc = chancreate(sizeof(Rune*), 1);
|
|
||||||
if((hostfd = start_host()) >= 0)
|
|
||||||
proccreate(hostreader, nil, BSIZE+1024);
|
|
||||||
|
|
||||||
histp = hist;
|
histp = hist;
|
||||||
menu2.item = menutext2;
|
menu2.item = menutext2;
|
||||||
|
@ -301,9 +293,18 @@ initialize(int argc, char **argv)
|
||||||
|
|
||||||
resize();
|
resize();
|
||||||
|
|
||||||
if(argc > 0) {
|
hc = chancreate(sizeof(Rune*), 1);
|
||||||
sendnchars(strlen(argv[0]),argv[0]);
|
if((hostfd = start_host()) >= 0)
|
||||||
sendnchars(1,"\n");
|
proccreate(hostreader, nil, BSIZE+1024);
|
||||||
|
|
||||||
|
while(*argv != nil){
|
||||||
|
sendnchars(strlen(*argv), *argv);
|
||||||
|
if(argv[1] == nil){
|
||||||
|
sendnchars(1, "\n");
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
sendnchars(1, " ");
|
||||||
|
argv++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue