in reply to Send signal to main thread

Signals and threads don't mix well. Neither on Windows nor on Unix / POSIX threads. Don't do it.

Update: cdarke points out that I'm mistaking the signals that threads implements for inter-thread signaling with the OS signals. As you are using the threads signals, ignore my comment.

Replies are listed 'Best First'.
Re^2: Send signal to main thread
by onelesd (Pilgrim) on Sep 02, 2011 at 05:43 UTC

    When using threads, catching a Ctrl-C to close up your program gracefully is a nightmare.

    While threads signals may work fine, catching signals from the terminal, such as Ctrl-C, still poses a difficult problem with no good solution (that I've encountered). There is no way to know which thread is going to receive the signal because the terminal sends the signal to the process group, not to a thread.