calling exit in a thread doesn't seem to kill the program

It’s a multi threaded program. In one of the threads, I call exit(0) and I am expecting it to kill the process. But it doesn’t! What can be the reason? How can I kill everything?

PS: It’s an emergency stopping so I don’t care about releasing the resources and other nice practices.

Need more info. What does happen? Are the threads able to run? QNX is a RTOS, so if higher priority threads are running, then lower priority threads in your process will not get the CPU time necessary to exit (cleanup always happens whether you explicitly code it or not).

Do you have a simple test case that shows the problem?

Unfortunately it’s difficult to reproduce the problem. What I can tell is that all the threads have the same priority level (default).

I substituted the exit call by abort. I can’t really be sure if it has solved the problem but it seems to have. I need more ample testing.

But your explanation makes sense, I had never thought about that before: I thought that the exit call was immediate. Is there any call that is immediate and just freeze/kills everything? It’s for a security feature that should freeze the system before it destroys itself…

When that happens do a pidin and check the thread/process state.

That won’t have “solved” the problem (my have masked it though). Abort does the same cleanup as exit does.

It is a different code path than exit() though… perhaps one of your internal threads ends up looping at a high priority in the exit() case (thus preventing the termer thread from running), but this doesn’t occur in the Abort() case?

But rather than speculate, why not trigger a ring buffer dump when a thread in your process calls exit (try _atexit() first)?

With a .kev file from the ring buffer there will be no need to speculate as to what happened…

You can simply send the reboot command to proc (see: sysmgr_reboot).