I have a C application running on AIX 6.1 using Websphere MQ 6.
The high level of the application is:
- Main C application spawns a seperate THREAD that does the LOOP to get message off the queue.
- When CTRL-C is hit I have a shutdown hook (via signals) that elegantly sets a “thread running variable” to FALSE and the thread ends.
The problem is whenever I hit CTRL-C I get the following reason code back:
2009 – MQRC_CONNECTION_BROKEN
So even though the MQGET on Websphere MQ is currently running the “connection handle” seems to “die” when I hit CTRL-C
Do I need to declare the connection handle in the thread as volatile or static or something else?
I assumed my thread shutdown was all 100%….and this connection broken issue is causing horrible logs to be generated on MQSeries…
I have posted a similar question to mqseries.net but was just wondering if I am missing some fundamental concept when CTRL-C is hit and my shutdown hook is triggered….
Any help will be greatly appreciated
Lynton
With the POSIX thread model consider this:
For any thread that calls pthread_sigmask() and blocks SIGINT, that thread will not receive the CTRC/C. Any of threads including the main thread, that have not blocked the signal will receive it. Handling the signal is different between the parent thread and the threads or LWP’s you create.
So in the main program, you call sigprocmask() to set up handling SIGINT. As you described.
All of the other threads, on their own, have to block SIGINT, by calling pthread_sigmask().