diff options
| author | Ron Yorston <rmy@pobox.com> | 2025-09-07 10:16:54 +0100 |
|---|---|---|
| committer | Ron Yorston <rmy@pobox.com> | 2025-09-07 10:16:54 +0100 |
| commit | 6609fa34057edfb842b2ca234db488fe4da982cc (patch) | |
| tree | 82c428a203869cc236e6c17e8d02d0c249f5b406 /shell | |
| parent | 719390a604f50a84a3bffbb168eadf83e733b020 (diff) | |
| download | busybox-w32-6609fa34057edfb842b2ca234db488fe4da982cc.tar.gz busybox-w32-6609fa34057edfb842b2ca234db488fe4da982cc.tar.bz2 busybox-w32-6609fa34057edfb842b2ca234db488fe4da982cc.zip | |
ash: jobs: Block signals during tcsetpgrp
Merge upstream commit 4ce8afe6b. This has no effect on Windows.
Diffstat (limited to 'shell')
| -rw-r--r-- | shell/ash.c | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/shell/ash.c b/shell/ash.c index 09e9ef605..408027305 100644 --- a/shell/ash.c +++ b/shell/ash.c | |||
| @@ -4712,7 +4712,22 @@ freejob(struct job *jp) | |||
| 4712 | static void | 4712 | static void |
| 4713 | xtcsetpgrp(int fd, pid_t pgrp) | 4713 | xtcsetpgrp(int fd, pid_t pgrp) |
| 4714 | { | 4714 | { |
| 4715 | if (tcsetpgrp(fd, pgrp)) | 4715 | int err; |
| 4716 | |||
| 4717 | sigblockall(NULL); | ||
| 4718 | err = tcsetpgrp(fd, pgrp); | ||
| 4719 | sigclearmask(); | ||
| 4720 | // Unmasking signals would cause any arrived signal to trigger, so why? | ||
| 4721 | // Generally yes, but there are exceptions. Such as: | ||
| 4722 | // """ | ||
| 4723 | // Attempts to use tcsetpgrp() from a process which is a member of | ||
| 4724 | // a background process group on a fd associated with its controlling | ||
| 4725 | // terminal shall cause the process group to be sent a SIGTTOU signal. | ||
| 4726 | // If the calling thread is blocking SIGTTOU signals or the process | ||
| 4727 | // is ignoring SIGTTOU signals, the process shall be allowed | ||
| 4728 | // to perform the operation, and no signal is sent.""" | ||
| 4729 | |||
| 4730 | if (err) | ||
| 4716 | ash_msg_and_raise_perror("can't set tty process group"); | 4731 | ash_msg_and_raise_perror("can't set tty process group"); |
| 4717 | } | 4732 | } |
| 4718 | 4733 | ||
