diff options
| author | _ov4 <ov4@ov4.org> | 2026-08-11 14:50:51 +0000 |
|---|---|---|
| committer | _ov4 <ov4@ov4.org> | 2026-08-11 14:50:51 +0000 |
| commit | 5182cddfc8e1f4c1ab80d90dedbf4fc95b71c3c2 (patch) | |
| tree | 9b020c5a322ccac9787874032e674d8885a3562a | |
| parent | 6e773674901a3b73abff74ad89dce4a6b9c02cd9 (diff) | |
be respectful to the original authors
| -rw-r--r-- | tsh.cc | 12 |
1 files changed, 9 insertions, 3 deletions
@@ -65,7 +65,7 @@ struct job_t jobs[MAXJOBS]; /* The job list */ void eval(char *cmdline); int builtin_cmd(char *c_str); void do_bgfg(char **argv); -void waitfg(sigset_t prev); +void waitfg(pid_t pid); void sigchld_handler(int sig); void sigtstp_handler(int sig); @@ -233,7 +233,8 @@ void eval(char *cmdline) // unblock all expect SIGCHILD sigprocmask(SIG_SETMASK, &prev_all, NULL); // we still leave SIGCHLD to be unblocked within waitfg() - waitfg(prev); + // this pid is USELESS!!! + waitfg(0); // and then unblock SIGCHLD sigprocmask(SIG_SETMASK, &prev, NULL); } @@ -332,8 +333,13 @@ void do_bgfg(char **argv) /* * waitfg - Block until process pid is no longer the foreground process */ -void waitfg(sigset_t prev) +void waitfg(pid_t pid) { + sigset_t prev; + // get current blocked signals + sigprocmask(0, NULL, &prev); + // remove SIGCHILD + sigdelset(&prev, SIGCHLD); clog << "waiting for pid "<< fgpid(jobs) << endl; while (fgpid(jobs) != 0) sigsuspend(&prev); |
