On Wed, 2016-11-30 at 10:41 +0000, Emmanuele Bassi wrote: https://developer.gnome.org/glib/stable/glib-Miscellaneous-Utility-Functions.html#g-atexit I have a related problem: In the last weeks I cleaned up the Nim GTK3 Editor application: https://github.com/ngtk3/NEd The primary problem was that I don't cared enough about thread safety -- I already fixed that following the hints from https://developer.gnome.org/gdk3/stable/gdk3-Threads.html#gdk-threads-add-idle 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 channel.send(msg) joinThreads(thread) if nsProcess != nil: nsProcess.terminate discard nsProcess.waitForExit nsProcess.close addQuitProc(cleanup) 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 https://wiki.gnome.org/HowDoI/GtkApplication Unfortunately so the cleanup proc is called already, while the main application is still running. _______________________________________________ gtk-list mailing list gtk-list@xxxxxxxxx https://mail.gnome.org/mailman/listinfo/gtk-list