![]() |
![]() |
![]() |
![]() |
Exit a Photon program
void PtExit( int return_code );
ph
This function is similar to exit(), except that PtExit() properly destroys all your application's widgets before exiting.
In a multithreaded application, a callback can call PtExit() in one thread while a second thread might be in the middle of an important operation, such as writing a file. To prevent the second thread from terminating early, call PtPreventExit() before starting the operation, and call PtAllowExit() when it's done.
![]() |
Instead of calling PtPreventExit() and PtAllowExit() directly, you're better off calling PtEnter() and PtLeave() with Pt_DELAY_EXIT set in the flags, because the Pt_DELAY_EXIT flag may not cause your application to lock up
in some situations where PtPreventExit() would. For a discussion of the difference between these functions and using Pt_DELAY_EXIT, see “Exiting a multithreaded program” in the Parallel Operations chapter of the Photon Programmer's Guide.
However, if you create a widget or add a Pt_CB_APP_EXIT callback inside a PtEnter(Pt_DELAY_EXIT) section, and another thread has already called PtExit(), there's no guarantee that the new widget will be destroyed, or the new callback called. |
Before exiting, PtExit():
![]() |
The callbacks in Pt_CB_APP_EXIT are called only once, even if PtExit() is called multiple times (for example by multiple threads, or recursively from a Pt_CB_APP_EXIT callback). |
This function doesn't return.
Photon
Safety: | |
---|---|
Cancellation point | No |
Interrupt handler | No |
Signal handler | Not applicable |
Thread | Yes |
PtAllowExit(), PtEnter(), PtLeave(), PtPreventExit()
exit() in the QNX Neutrino Library Reference
![]() |
![]() |
![]() |
![]() |