Author: damoxc
Revision: 5842
Log:
improve the forking code
Diff:
Modified: branches/1.2_RC/deluge/ui/web/web.py
===================================================================
--- branches/1.2_RC/deluge/ui/web/web.py 2009-10-13 12:01:20 UTC (rev
5841)
+++ branches/1.2_RC/deluge/ui/web/web.py 2009-10-13 15:20:45 UTC (rev
5842)
@@ -77,10 +77,26 @@
def start(self):
super(Web, self).start()
- if self.options.fork:
+ import deluge.common
+ # Steps taken from http://www.faqs.org/faqs/unix-faq/programmer/faq/
+ # Section 1.7
+ if self.options.fork and not deluge.common.windows_check():
+ # fork() so the parent can exit, returns control to the command
line
+ # or shell invoking the program.
if os.fork():
exit(0)
+ # setsid() to become a process group and session group leader.
+ os.setsid()
+
+ # fork() again so the parent, (the session group leader), can exit.
+ if os.fork():
+ exit(0)
+
+ # chdir() to esnure that our process doesn't keep any directory in
+ # use that may prevent a filesystem unmount.
+ import deluge.configmanager
+ os.chdir(deluge.configmanager.get_config_dir())
import server
self.__server = server.DelugeWeb()
Modified: trunk/deluge/ui/web/web.py
===================================================================
--- trunk/deluge/ui/web/web.py 2009-10-13 12:01:20 UTC (rev 5841)
+++ trunk/deluge/ui/web/web.py 2009-10-13 15:20:45 UTC (rev 5842)
@@ -77,10 +77,26 @@
def start(self):
super(Web, self).start()
- if self.options.fork:
+ import deluge.common
+ # Steps taken from http://www.faqs.org/faqs/unix-faq/programmer/faq/
+ # Section 1.7
+ if self.options.fork and not deluge.common.windows_check():
+ # fork() so the parent can exit, returns control to the command
line
+ # or shell invoking the program.
if os.fork():
exit(0)
+ # setsid() to become a process group and session group leader.
+ os.setsid()
+
+ # fork() again so the parent, (the session group leader), can exit.
+ if os.fork():
+ exit(0)
+
+ # chdir() to esnure that our process doesn't keep any directory in
+ # use that may prevent a filesystem unmount.
+ import deluge.configmanager
+ os.chdir(deluge.configmanager.get_config_dir())
import server
self.__server = server.DelugeWeb()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"deluge-commit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/deluge-commit?hl=en
-~----------~----~----~----~------~----~------~--~---