I'm working on a multilevel C ++ application with freewluts in Linux. Strangely, an call (callback) is called and is completed by calling the calling exit () in one of my threads, but fails to exit my program. Instead, it is hanging in a selection () call in the GLTT library according to the GLUT.
I also have a keyboard callback that presses 'q'. GLUTTU gets cured if I press the 'q' while hanging the program.
There is no problem with this type of documentation. The documentation says that exit () is to stop the entire process, and not just one thread, so it is not so. I am confused. Do you have an idea?
EDIT: I have found the problem I was wrong that the handler of the exit was finished. A library function call was waiting on a mute x that was previously locked when called exit (). GLUT has taken advantage of the free time now thanks everyone for your responses. Note: Exit () is a C function.
C ++ 03
As a language, C is not the concept of thread.
Threads are usually added to C by library support, so you need to read the library documents that affect the calling exit () from the thread which is not the main thread.
This is probably not portable for threading implementation.
Your main condition is to call only () exit the main thread.
In a child thread, you should set some position that is seen by the main thread. Let the main thread see this situation and call it manually. Note also man can hang some threading libraries to get out on the thread if their child threads are still running, so if you want your code to be portable, wait for the main thread to wait for all the children would be better.
In C ++ 11
Now when C ++ is more pronounced with language in there, there is more to it Exit the function () This international standard has additional behavior: A ???? First of all, the threads are connected with the storage period and are connected to the current thread, the objects are destroyed with the static storage period, and the registered functions are called by calling the entity. one ???? Next, with all unwanted buffering data, all open-stream streams (in the form of mediated by the signature declared by the signature), all open sect streams are closed, and all files are created by calling templile (). ???? Finally, the control in the host environment is back. If the status is zero or EXIT_SUCCESS, then the successful completion of an implementation-defined form of the situation has returned. If the situation is EXIT_FAILURE, an implementation-defined form of status failure is given. Otherwise the situation is back-implementation-defined.
See 3.6.3 for the order of destruction and call (Automatic object is not destroyed as a result of calling exit). If the control leaves a registered function called the function Because the function does not provide the handler for a thrown exception, then std :: terminate () will be called (15.5). 1).
Comments
Post a Comment