Opened 16 years ago
Closed 9 years ago
#3417 closed bug (fixed)
tcsetpgrp() causes the shell "bsh" to hang infinitely while trying to set tty process group
Reported by: | schily | Owned by: | axeld |
---|---|---|---|
Priority: | normal | Milestone: | R1 |
Component: | System/Kernel | Version: | R1/Development |
Keywords: | Cc: | ||
Blocked By: | Blocking: | ||
Platform: | All |
Description
bsh forks and the child process calls tcsetpgrp() in order to set the TTY process group of the child to the child process. This is needed in order to redirect signals only to the child.
after bsh calls tcsetpgrp(), tcsetpgrp() calls ioctl() and hangs inside the ioctl.
Workaround: edit the Makefile for bsh and comment out the line with -DJOBCONTROL
Note that bsh worked without problems on Zeta.
bsh is inside the schily source consolidation at:
ftp://ftp.berlios.de/pub/schily/schily-dist/preliminary-2.tar.bz2
The named file is the first version that was ported to Haiku
Attachments (2)
Change History (8)
by , 9 years ago
Attachment: | 0001-kernel-Don-t-send-SIGTTOU-if-calling-thread-is-block.patch added |
---|
comment:1 by , 9 years ago
patch: | 0 → 1 |
---|
comment:2 by , 9 years ago
I've added a patch that should fix this problem.
When a member of a background process group tries to change the foreground process group of its controlling terminal, POSIX says SIGTTOU should be sent unless the process is ignoring it or the calling thread is blocking it. The existing code checked the former case but not the latter, which meant the calling thread could get stuck in a loop while the system call was continually restarted.
by , 9 years ago
Attachment: | tcsetpgrp-test.c added |
---|
Short program that demonstrates the problem and the fix
comment:3 by , 9 years ago
I've also added a program that demonstrates the problem. Without the patch applied, the program will terminate normally when invoked directly but loop forever when invoked using either strace
or the debugger (as it moves itself to a background process group). With the patch applied the program will terminate normally in both cases.
comment:4 by , 9 years ago
Component: | - General → System/Kernel |
---|---|
Version: | R1/pre-alpha1 → R1/Development |
Don't send SIGTTOU if the calling thread is blocking it