Add foreground process support to init and sh.

This commit is contained in:
Jonas 'Sortie' Termansen 2013-06-12 02:26:22 +02:00
parent c8f302df1a
commit 311423856e
2 changed files with 3 additions and 0 deletions

View File

@ -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 };

View File

@ -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 )