This is the mail archive of the
gdb@sources.redhat.com
mailing list for the GDB project.
SIGTTOU on multi-threaded programs
- From: Vladimir Prus <ghost at cs dot msu dot su>
- To: gdb at sources dot redhat dot com
- Date: Wed, 24 Mar 2004 13:28:38 +0300
- Subject: SIGTTOU on multi-threaded programs
Hello,
I'm having trouble running multi-threaded programs under gdb, soon after
starting the shell says that gdb is "stopped" -- and it seems like it
receives SIGTTOU.
Here's a simple program:
#include <pthread.h>
void* thread(void*)
{
for(;;);
}
int main()
{
pthread_t p1;
pthread_create(&p1, 0, thread, 0);
return 0;
}
When I run
stty tostop
g++ -g threads.cpp -pthread
gdb ./a.out
and then "run", I see:
[1]+ Stopped gdb a.out
The "stty tostop" makes the terminal send 'SIGTTOU' if background process
writes something to console. The problem is that midnight commander also sets
this flag -- which means I can't debug multi-threaded programs under MC.
The debugged program and gdb have different process group id, and debugged
program is initially in the foreground -- so gdb in in background. It looks
like gdb tries to output something while it's still in background, and
recieves the signal.
Is this a known issue? What can be done about it? I've worked this around for
one program using code that adds the program to the same process group as the
parent, so both the program and gdb are consired to be in foreground by the
terminal, but that does not look the right solution.
I'm using "GNU gdb 6.0".
Thanks in advance,
Volodya