Add foreground process support to init and sh.
This commit is contained in:
parent
c8f302df1a
commit
311423856e
|
@ -40,6 +40,7 @@ int child()
|
||||||
setenv("INIT_PID", init_pid_str, 1);
|
setenv("INIT_PID", init_pid_str, 1);
|
||||||
|
|
||||||
setpgid(0, 0);
|
setpgid(0, 0);
|
||||||
|
tcsetpgrp(0, getpid());
|
||||||
|
|
||||||
const char* programname = "sh";
|
const char* programname = "sh";
|
||||||
const char* newargv[] = { programname, NULL };
|
const char* newargv[] = { programname, NULL };
|
||||||
|
|
|
@ -193,11 +193,13 @@ readcmd:
|
||||||
|
|
||||||
status = internalresult;
|
status = internalresult;
|
||||||
int exitstatus;
|
int exitstatus;
|
||||||
|
tcsetpgrp(0, pgid);
|
||||||
if ( !internal && waitpid(childpid, &exitstatus, 0) < 0 )
|
if ( !internal && waitpid(childpid, &exitstatus, 0) < 0 )
|
||||||
{
|
{
|
||||||
perror("waitpid");
|
perror("waitpid");
|
||||||
return 127;
|
return 127;
|
||||||
}
|
}
|
||||||
|
tcsetpgrp(0, getpgid(0));
|
||||||
|
|
||||||
// TODO: HACK: Most signals can't kill processes yet.
|
// TODO: HACK: Most signals can't kill processes yet.
|
||||||
if ( WEXITSTATUS(exitstatus) == 128 + SIGINT )
|
if ( WEXITSTATUS(exitstatus) == 128 + SIGINT )
|
||||||
|
|
Loading…
Reference in New Issue