This is the mail archive of the gdb@sources.redhat.com mailing list for the GDB project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

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



Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]