[GRASS-SVN] r58580 - grass/trunk/gui/wxpython/core
svn_grass at osgeo.org
svn_grass at osgeo.org
Wed Jan 1 18:56:03 PST 2014
Author: huhabla
Date: 2014-01-01 18:56:02 -0800 (Wed, 01 Jan 2014)
New Revision: 58580
Modified:
grass/trunk/gui/wxpython/core/utils.py
Log:
Fixed wrongly placed os._exit() call, that prevents exit handler from work.
The child should not call os._exit(), otherwise existing subprocesses will not
terminated correctly. os._exit() should be called in the parent.
Modified: grass/trunk/gui/wxpython/core/utils.py
===================================================================
--- grass/trunk/gui/wxpython/core/utils.py 2014-01-02 02:53:00 UTC (rev 58579)
+++ grass/trunk/gui/wxpython/core/utils.py 2014-01-02 02:56:02 UTC (rev 58580)
@@ -1063,12 +1063,23 @@
# launch GUI in the background
child_pid = os.fork()
if child_pid == 0:
+ # To become the session leader of this new session and the process group
+ # leader of the new process group, we call os.setsid(). The process is
+ # also guaranteed not to have a controlling terminal.
+ os.setsid()
mainfn()
- os._exit(0)
+ else:
+ # exit() or _exit()?
+ # _exit is like exit(), but it doesn't call any functions registered
+ # with atexit (and on_exit) or any registered signal handlers. It also
+ # closes any open file descriptors. Using exit() may cause all stdio
+ # streams to be flushed twice and any temporary files may be unexpectedly
+ # removed. It's therefore recommended that child branches of a fork()
+ # and the parent branch(es) of a daemon use _exit().
+ os._exit(0) # Exit parent of the child.
else:
mainfn()
-
def PilImageToWxImage(pilImage, copyAlpha = True):
"""!Convert PIL image to wx.Image
More information about the grass-commit
mailing list