Change sigTTOU/TTIN to IGNORE by default
Simon Marlow
simonmar at microsoft.com
Mon Jan 15 07:52:03 EST 2001
> In fact I can produce a simple example, either. So just the facts:
>
> perftest at monster [11:46:35]> ./Reader &
> [2] 86029
> perftest at monster [11:46:40]> jobs
> [2]+ Stopped ./Reader
>
> Sourcecode-snippet of Reader:
>
> > main = do
> > -- Posix.installHandler Posix.sigTTOU Posix.Ignore Nothing
> > hSetBuffering stdout NoBuffering
> > Distributed.start (do
> > register "Reader"
> > ....
>
> and the relevant fragment of Distributed.start up to the first few
> putStrs:
>
> > start :: DIO msg () -> String -> IO ()
> > start f node = do
> > putStr "DHS: Starting"
> > putStr " Arguments"
> > args <- DHSOptions.getArgs
> > ...
>
> Inserting a linefeed or using putStrLn don´t cause any change.
This is truly bizarre. I've tracked it down to a tcgetattr/tcsetattr
pair in setBuffering. If you leave out the hSetBuffering call then the
process can be backgrounded without stopping.
What's weird is that the tcsetattr doesn't affect the TOSTOP flag at all
(which is the flag that tells the OS whether the process should be
stopped on background TTY output), and the TOSTOP flag starts off unset.
The following C program illustrates this:
#include <stdio.h>
#include <termios.h>
#include <unistd.h>
int main(void) {
struct termios tio;
if (tcgetattr(1, &tio) < 0) { exit(1); }
if (tcsetattr(1, TCSANOW, &tio) < 0) { exit(1); }
printf("hello world\n");
exit(0);
}
running "./a.out &" suspends the process. If you comment out the
tcsetattr line, then it doesn't get suspended. But we're not changing
any of the terminal flags, simply setting the same ones again.
I'm totally stumped! I can't see any reason why this should happen. It
happens on both Linux & Solaris.
Any ideas, anyone?
Cheers,
Simon
More information about the Glasgow-haskell-bugs
mailing list