diff options
author | Andreas Kling <awesomekling@gmail.com> | 2018-11-02 13:14:25 +0100 |
---|---|---|
committer | Andreas Kling <awesomekling@gmail.com> | 2018-11-02 13:14:25 +0100 |
commit | 621217ffeb9bddec866ad8895bd01973977f2848 (patch) | |
tree | a093956e51c52f13cc0f7003e278bc255f83acac /Userland/sh.cpp | |
parent | d8f0dd6f3b36987c2a8021e16341dda16cbb7ab1 (diff) | |
download | serenity-621217ffeb9bddec866ad8895bd01973977f2848.zip |
Add tcsetpgrp()+tcgetpgrp().
One more step on the path to being able to ^C a runaway process. :^)
Diffstat (limited to 'Userland/sh.cpp')
-rw-r--r-- | Userland/sh.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/Userland/sh.cpp b/Userland/sh.cpp index 7ad8361153..c5669449c5 100644 --- a/Userland/sh.cpp +++ b/Userland/sh.cpp @@ -142,10 +142,17 @@ static int runcmd(char* cmd) return 1; } + // FIXME: This is racy, since spawn has already started the new process. + // Once I have fork()+exec(), pgrp setup can be done in the child before exec()ing. + tcsetpgrp(0, ret); + // FIXME: waitpid should give us the spawned process's exit status int wstatus = 0; waitpid(ret, &wstatus, 0); + // FIXME: Racy as mentioned above. Rework once we have fork()+exec(). + tcsetpgrp(0, getpid()); + if (WIFEXITED(wstatus)) { //printf("Exited normally with status %d\n", WEXITSTATUS(wstatus)); } else { @@ -173,6 +180,8 @@ int main(int, char**) { g = new GlobalState; g->sid = setsid(); + tcsetpgrp(0, getpgrp()); + int rc = gethostname(g->hostname, sizeof(g->hostname)); if (rc < 0) perror("gethostname"); |