safely terminate application
Hi,
I have got some problems terminating my RT application, I have very strange behavours. either locking application, either TERMINATE signal does not seem being propagated.
I am using a SIGTERM handler to call a cleanup func to delete everything.
I noticed that if I delete nothing , it seems to quit fine (altough there may be lot of memory leaks,etc...)
Unfortunately, I don't have the problem using a small regression test ... my problem concerns a real life application, with rt_tasks, rt_pipes, mutex,rtdm driver ...
At initialisation of program I am loading an xmlfile using libxml2 api. I strongly suspect this library being intrusive, since it modifiess some signals, is using mutexes....and may have an impact in the way my application quits.
http://www.xmlsoft.org/threads.html
if some people have any idea on how I could deal with this problem...
Regards,
Steph
Quoted 8 lines · Stéphane ANCELOT
Hi,
I have got some problems terminating my RT application, I have very strange behavours.
either locking application, either TERMINATE signal does not seem being propagated.I am using a SIGTERM handler to call a cleanup func to delete everything.
This is a bad solution. Most functions, including cleanup functions like, say, pthread_mutex_destroy, are not "async-signal-safe", they can not be called from the context of a signal handler. For this reason, using signals with threaded applications is hard to get right.
For instance, the "printf" function uses a mutex to protect concurrent access to the underlying FILE *. If a signal handler calls printf on a thread which had the mutex locked because it was in the middle of a printf, you get a deadlock.
Quoted 3 lines
I noticed that if I delete nothing , it seems to quit fine (altough there may be lot of memory leaks,etc...)
No, there will not be any memory leak. The memory reserved by an application is automatically returned to the system when the application terminates. On the Xenomai side, all Xenomai objects created by your application are destroyed automatically.
Signature · 2 lines
Gilles. https://click-hack.org