← Commit list

4ce8afe6b

Denys Vlasenko
Denys Vlasenko
2025-08-09
SUCCESS Duration: 153s

Subject

ahs: jobs: Block signals during tcsetpgrp

Binary

No binary (build failed)

Architecture & Compiler Flags

Architecture: x86_64-linux-gnu Compiler: gcc (Ubuntu 11.4.0-1ubuntu1~22.04.3) 11.4.0

—

Build Log

(log yok)

Commit Diff GitHub →

shell/ash.c+16 -1
@@ -4102,7 +4102,22 @@ freejob(struct job *jp)
static void
xtcsetpgrp(int fd, pid_t pgrp)
{
- if (tcsetpgrp(fd, pgrp))
+ int err;
+
+ sigblockall(NULL);
+ err = tcsetpgrp(fd, pgrp);
+ sigclearmask();
+ // Unmasking signals would cause any arrived signal to trigger, so why?
+ // Generally yes, but there are exceptions. Such as:
+ // """
+ // Attempts to use tcsetpgrp() from a process which is a member of
+ // a background process group on a fd associated with its controlling
+ // terminal shall cause the process group to be sent a SIGTTOU signal.
+ // If the calling thread is blocking SIGTTOU signals or the process
+ // is ignoring SIGTTOU signals, the process shall be allowed
+ // to perform the operation, and no signal is sent."""
+
+ if (err)
ash_msg_and_raise_perror("can't set tty process group");
}