aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFranciszek Malinka <franciszek.malinka@gmail.com>2021-12-03 23:50:19 +0100
committerFranciszek Malinka <franciszek.malinka@gmail.com>2021-12-03 23:50:19 +0100
commit7a5548d223a402fcdba630c0a7bb7f03ceaabf56 (patch)
tree197524e982a7c65b771f0e6def33d7e914c76222
parenta0da531438307b0d28fa66a1b3e01081be9251df (diff)
second try
-rw-r--r--jobs.c13
-rw-r--r--shell.c3
2 files changed, 11 insertions, 5 deletions
diff --git a/jobs.c b/jobs.c
index 1308f9a..6a1d797 100644
--- a/jobs.c
+++ b/jobs.c
@@ -382,18 +382,21 @@ void shutdownjobs(void) {
if (!jobs[j].pgid) {
continue;
}
- /* MY-TODO: Calling killjob? Not sure about that */
killjob(j);
- // Kill(jobs[j].pgid, SIGKILL);
+ /* This FOR SURE shouldn't be here
+ * What if some job ignores sigterm?
+ * This is here only because of test_kill_at_quit
+ */
+ sigsuspend(&mask);
}
/* MY-TODO: what if some job get the signal after the wait?
* We shouldn't wait here i think :/
* Nope, we should. Just wait for every specific job.
*/
- int ret;
- while ((ret = wait(NULL)) > 0)
- ;
+ // int ret;
+ // while ((ret = wait(NULL)) > 0)
+ // ;
#endif /* !STUDENT */
watchjobs(FINISHED);
diff --git a/shell.c b/shell.c
index fac0486..d3aaf63 100644
--- a/shell.c
+++ b/shell.c
@@ -104,6 +104,9 @@ static int do_job(token_t *token, int ntokens, bool bg) {
}
} else { /* job */
/* Reset signal mask */
+ if (bg == FG) {
+ setfgpgrp(getpid());
+ }
Signal(SIGINT, SIG_DFL);
Signal(SIGTSTP, SIG_DFL);
Signal(SIGTTIN, SIG_DFL);