#1108042 bash: Odd behaviour in bash parent when bash subshell gets SIGKILLed - SIGTTIN

Package:
bash
Source:
bash
Description:
GNU Bourne Again SHell
Submitter:
Tim Connors
Date:
2025-06-19 15:41:03 UTC
Severity:
normal
#1108042#5
Date:
2025-06-19 15:40:22 UTC
From:
To:
I invoke the script below, which just runs a bash shell, waits for it
to exit, then reads from stdin (attached to the terminal).  If I kill
the child shell with SIGKILL only (all my other tested signals were
received and dealt with by the relevant handlers, and if control was
returned back to the parent shell, it was able to then perform the
reads as you expect), then the final read causes the script to be
interrupted waiting for the terminal.

The intermediate `read -t`s don't need to be performed to result in
what I observed.  The first read without a timeout causes the SIGTTIN,
or the first read that actually has any data waiting for it, likewise.
#!/bin/bash

bash
exit=$?

echo exit=$exit

echo "purging"
while read -t 0.1 -p "purging stdin > " purge ; do
   echo "purging STDIN: $purge"
done
echo purged: "$purge"

echo attempt 2
read -t 1 -p "read attempt 2 with timeout 1 > " timeout1
echo "timeout1=$timeout2"

echo attempt 3

read -p "read attempt 3 without timeout > " r
echo "r=$r"




Tests:

tconnorstest@dirac:~$ /tmp/minimal-test
tconnorstest@dirac:~$ kill -9 $$
/tmp/minimal-test: line 3: 61705 Killed                  bash
exit=137
purging
purging stdin > purged:
attempt 2
read attempt 2 with timeout 1 > timeout1=
attempt 3
read attempt 3 without timeout >
[1]+  Stopped                 /tmp/minimal-test


Run the test again quickly entering some text ("a") followed by enter:

tconnorstest@dirac:~$ /tmp/minimal-test
tconnorstest@dirac:~$ kill -9 $$
/tmp/minimal-test: line 3: 63357 Killed                  bash
exit=137
purging
purging stdin > purged:
attempt 2
read attempt 2 with timeout 1 > a

[2]+  Stopped                 /tmp/minimal-test


Relevant moments of the strace of the script looks like this:

Kill and be killed:

149617 01:28:55.359452 read(0, "9", 1)  = 1
149617 01:28:55.359670 pselect6(1, [0], NULL, [0], {tv_sec=0, tv_nsec=0}, {sigmask=NULL, sigsetsize=8}) = 0 (Timeout)
149617 01:28:55.359880 write(2, "9", 1) = 1
149617 01:28:55.360079 pselect6(1, [0], NULL, NULL, NULL, {sigmask=[], sigsetsize=8}) = 1 (in [0])
149617 01:28:55.415543 read(0, " ", 1)  = 1
149617 01:28:55.415772 pselect6(1, [0], NULL, [0], {tv_sec=0, tv_nsec=0}, {sigmask=NULL, sigsetsize=8}) = 0 (Timeout)
149617 01:28:55.415988 write(2, " ", 1) = 1
149617 01:28:55.416170 pselect6(1, [0], NULL, NULL, NULL, {sigmask=[], sigsetsize=8}) = 1 (in [0])
149617 01:28:55.631923 read(0, "$", 1)  = 1
149617 01:28:55.632259 pselect6(1, [0], NULL, [0], {tv_sec=0, tv_nsec=0}, {sigmask=NULL, sigsetsize=8}) = 0 (Timeout)
149617 01:28:55.632554 write(2, "$", 1) = 1
149617 01:28:55.632873 pselect6(1, [0], NULL, NULL, NULL, {sigmask=[], sigsetsize=8}) = 1 (in [0])
149617 01:28:55.831513 read(0, "$", 1)  = 1
149617 01:28:55.831704 pselect6(1, [0], NULL, [0], {tv_sec=0, tv_nsec=0}, {sigmask=NULL, sigsetsize=8}) = 0 (Timeout)
149617 01:28:55.831908 write(2, "$", 1) = 1
149617 01:28:55.832089 pselect6(1, [0], NULL, NULL, NULL, {sigmask=[], sigsetsize=8}) = 1 (in [0])
149617 01:28:56.839860 read(0, "\r", 1) = 1
149617 01:28:56.840201 write(2, "\n", 1) = 1
149617 01:28:56.840508 write(2, "\33[?2004l\r", 9) = 9
149617 01:28:56.840804 ioctl(0, TCGETS, {c_iflag=IXON|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
149617 01:28:56.841159 ioctl(0, SNDCTL_TMR_STOP or TCSETSW, {c_iflag=ICRNL|IXON|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
149617 01:28:56.841504 ioctl(0, TCGETS, {c_iflag=ICRNL|IXON|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
149617 01:28:56.841866 rt_sigaction(SIGINT, {sa_handler=0x563b1d1e4aa0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fead07d0050}, {sa_handler=0x563b1d242d00, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fead07d0050}, 8) = 0
149617 01:28:56.842224 rt_sigaction(SIGHUP, {sa_handler=0x563b1d1e4f30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fead07d0050}, {sa_handler=0x563b1d242d00, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fead07d0050}, 8) = 0
149617 01:28:56.842578 rt_sigaction(SIGALRM, {sa_handler=0x563b1d1e4f30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fead07d0050}, {sa_handler=0x563b1d242d00, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fead07d0050}, 8) = 0
149617 01:28:56.842938 rt_sigaction(SIGWINCH, {sa_handler=0x563b1d1e4520, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fead07d0050}, {sa_handler=0x563b1d242d10, sa_mask=[], sa_flags=SA_RESTORER|SA_RESTART, sa_restorer=0x7fead07d0050}, 8) = 0
149617 01:28:56.843286 rt_sigaction(SIGINT, {sa_handler=0x563b1d1e4aa0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fead07d0050}, {sa_handler=0x563b1d1e4aa0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fead07d0050}, 8) = 0
149617 01:28:56.843652 kill(149617, SIGKILL) = ?
149617 01:28:56.844975 +++ killed by SIGKILL +++
149616 01:28:56.845054 <... wait4 resumed>[{WIFSIGNALED(s) && WTERMSIG(s) == SIGKILL}], 0, NULL) = 149617
149616 01:28:56.845165 rt_sigaction(SIGINT, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=0x559e0a0a90b0, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, 8) = 0
149616 01:28:56.845364 ioctl(2, TIOCGWINSZ, {ws_row=32, ws_col=119, ws_xpixel=1328, ws_ypixel=708}) = 0
149616 01:28:56.845582 openat(AT_FDCWD, "/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
149616 01:28:56.845817 newfstatat(3, "", {st_mode=S_IFREG|0644, st_size=2996, ...}, AT_EMPTY_PATH) = 0
149616 01:28:56.846028 read(3, "# Locale name alias data base.\n#"..., 4096) = 2996
149616 01:28:56.846213 read(3, "", 4096) = 0
149616 01:28:56.846372 close(3)         = 0
149616 01:28:56.846529 openat(AT_FDCWD, "/usr/share/locale/en_AU.UTF-8/LC_MESSAGES/bash.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.846696 openat(AT_FDCWD, "/usr/share/locale/en_AU.utf8/LC_MESSAGES/bash.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.846869 openat(AT_FDCWD, "/usr/share/locale/en_AU/LC_MESSAGES/bash.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.847034 openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/bash.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.847213 openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/bash.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.847384 openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/bash.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.847558 newfstatat(2, "", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x150), ...}, AT_EMPTY_PATH) = 0
149616 01:28:56.847774 openat(AT_FDCWD, "/usr/share/locale/en_AU.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.847951 openat(AT_FDCWD, "/usr/share/locale/en_AU.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.848122 openat(AT_FDCWD, "/usr/share/locale/en_AU/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.848281 openat(AT_FDCWD, "/usr/share/locale/en.UTF-8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.848430 openat(AT_FDCWD, "/usr/share/locale/en.utf8/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.848600 openat(AT_FDCWD, "/usr/share/locale/en/LC_MESSAGES/libc.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
149616 01:28:56.848760 write(2, "/tmp/minimal-test: line 3: 14961"..., 63) = 63
149616 01:28:56.848942 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
149616 01:28:56.849101 --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=149617, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=1 /* 0.01 s */} ---
149616 01:28:56.849196 wait4(-1, 0x7fff4683c8d0, WNOHANG, NULL) = -1 ECHILD (No child processes)
149616 01:28:56.849347 rt_sigreturn({mask=[]}) = 0
149616 01:28:56.849506 read(255, "exit=$?\n\necho exit=$exit\n\necho \""..., 343) = 325
149616 01:28:56.849690 newfstatat(1, "", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x150), ...}, AT_EMPTY_PATH) = 0
149616 01:28:56.849865 write(1, "exit=137\n", 9) = 9
149616 01:28:56.850039 write(1, "purging\n", 8) = 8
149616 01:28:56.850234 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
149616 01:28:56.850443 ioctl(0, TCGETS, {c_iflag=ICRNL|IXON|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
149616 01:28:56.850620 newfstatat(0, "", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x150), ...}, AT_EMPTY_PATH) = 0


# Readline getting ready with signal handlers?

149616 01:28:56.850777 rt_sigaction(SIGHUP, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.850988 rt_sigaction(SIGINT, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, 8) = 0
149616 01:28:56.851245 rt_sigaction(SIGILL, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.851490 rt_sigaction(SIGTRAP, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.851696 rt_sigaction(SIGABRT, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.851956 rt_sigaction(SIGFPE, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.852240 rt_sigaction(SIGBUS, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.852470 rt_sigaction(SIGSEGV, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.852665 rt_sigaction(SIGSYS, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.852884 rt_sigaction(SIGPIPE, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.853114 rt_sigaction(SIGALRM, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.853324 rt_sigaction(SIGTERM, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.853521 rt_sigaction(SIGXCPU, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.853727 rt_sigaction(SIGXFSZ, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.853903 rt_sigaction(SIGVTALRM, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.854040 rt_sigaction(SIGUSR1, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.854180 rt_sigaction(SIGUSR2, {sa_handler=0x559e0a0cdf30, sa_mask=[HUP INT ILL TRAP ABRT BUS FPE USR1 SEGV USR2 PIPE ALRM TERM XCPU XFSZ VTALRM SYS], sa_flags=SA_RESTORER, sa_restorer=0x7fa5e23c6050}, {sa_handler=SIG_DFL, sa_mask=[], sa_flags=0}, 8) = 0
149616 01:28:56.854382 gettimeofday({tv_sec=1750346936, tv_usec=854449}, NULL) = 0
149616 01:28:56.854557 gettimeofday({tv_sec=1750346936, tv_usec=854602}, NULL) = 0
149616 01:28:56.854716 write(2, "purging stdin > ", 16) = 16
149616 01:28:56.854964 gettimeofday({tv_sec=1750346936, tv_usec=855012}, NULL) = 0
149616 01:28:56.855157 gettimeofday({tv_sec=1750346936, tv_usec=855204}, NULL) = 0
149616 01:28:56.855342 rt_sigprocmask(SIG_SETMASK, [CHLD], [], 8) = 0
149616 01:28:56.855534 gettimeofday({tv_sec=1750346936, tv_usec=855580}, NULL) = 0
149616 01:28:56.855746 gettimeofday({tv_sec=1750346936, tv_usec=855807}, NULL) = 0

# Invoking the first timeout, 0.1 seconds, no read

149616 01:28:56.855889 pselect6(1, [0], NULL, NULL, {tv_sec=0, tv_nsec=98642000}, {sigmask=[CHLD], sigsetsize=8}) = 0 (Timeout)
149616 01:28:56.954908 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
149616 01:28:56.955153 rt_sigprocmask(SIG_BLOCK, [CHLD], [], 8) = 0
149616 01:28:56.955351 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
149616 01:28:56.955576 write(1, "purged: \n", 9) = 9
149616 01:28:56.955855 write(1, "attempt 2\n", 10) = 10
149616 01:28:56.956052 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
149616 01:28:56.956216 ioctl(0, TCGETS, {c_iflag=ICRNL|IXON|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
149616 01:28:56.956372 newfstatat(0, "", {st_mode=S_IFCHR|0620, st_rdev=makedev(0x88, 0x150), ...}, AT_EMPTY_PATH) = 0
149616 01:28:56.956520 gettimeofday({tv_sec=1750346936, tv_usec=956555}, NULL) = 0
149616 01:28:56.956658 gettimeofday({tv_sec=1750346936, tv_usec=956701}, NULL) = 0
149616 01:28:56.956819 write(2, "read attempt 2 with timeout 1 > ", 32) = 32
149616 01:28:56.956980 gettimeofday({tv_sec=1750346936, tv_usec=957066}, NULL) = 0
149616 01:28:56.957232 gettimeofday({tv_sec=1750346936, tv_usec=957276}, NULL) = 0
149616 01:28:56.957391 rt_sigprocmask(SIG_SETMASK, [CHLD], [], 8) = 0
149616 01:28:56.957551 gettimeofday({tv_sec=1750346936, tv_usec=957588}, NULL) = 0
149616 01:28:56.957723 gettimeofday({tv_sec=1750346936, tv_usec=957802}, NULL) = 0

# second timeout, 1 second, no read

149616 01:28:56.957952 pselect6(1, [0], NULL, NULL, {tv_sec=0, tv_nsec=998753000}, {sigmask=[CHLD], sigsetsize=8}) = 0 (Timeout)
149616 01:28:57.958035 rt_sigprocmask(SIG_SETMASK, [], NULL, 8) = 0
149616 01:28:57.958286 write(1, "timeout1=\n", 10) = 10
149616 01:28:57.958560 write(1, "attempt 3\n", 10) = 10
149616 01:28:57.958768 rt_sigprocmask(SIG_BLOCK, NULL, [], 8) = 0
149616 01:28:57.958957 ioctl(0, TCGETS, {c_iflag=ICRNL|IXON|IUTF8, c_oflag=NL0|CR0|TAB0|BS0|VT0|FF0|OPOST|ONLCR, c_cflag=B38400|CS8|CREAD, c_lflag=ISIG|ICANON|ECHO|ECHOE|ECHOK|IEXTEN|ECHOCTL|ECHOKE, ...}) = 0
149616 01:28:57.959131 write(2, "read attempt 3 without timeout >"..., 33) = 33

# Bugger, can't read:

149616 01:28:57.959293 read(0, 0x559e0a189f40, 4096) = ? ERESTARTSYS (To be restarted if SA_RESTART is set)
149616 01:28:57.959453 --- SIGTTIN {si_signo=SIGTTIN, si_code=SI_KERNEL} ---
149616 01:28:57.959537 --- stopped by SIGTTIN ---




ksh does not exhibit the same brokenness, so I don't think it's my (lack of) understanding of signals.