C atexit(), g_atexit -- how to cleanup when a gtk application crashes?

On Wed, 2016-11-30 at 10:41 +0000, Emmanuele Bassi wrote:


I have a related problem:

In the last weeks I cleaned up the Nim GTK3 Editor application:


The primary problem was that I don't cared enough about thread safety
-- I already fixed that following the hints from


One remaining problem is, that I create a second thread and a new
process in the application.

And it would be good if thread and process is terminated when a program
crash of the appication occurs.

Current solution is 

proc cleanup {.noconv.} =
  var msg: StatusMsg
  msg.filepath = nil
  if nsProcess != nil:
    discard nsProcess.waitForExit


which is internally based on C lib atexit() function. Seems to work
fine generally, but problem is the GTK3 process handling:

./ned file1.nim &
./ned file2.nim

file2.nim is send to the primary process, and second process
terminates, as described by


Unfortunately so the cleanup proc is called already, while the main
application is still running.

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]