Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Python
[2.4.2/Linux] Getting Python to fork?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Bernard, post: 3430419"] this works out for me: def tryToFork(cbk, fork=True): ''' If possible, start the process as a daemon under linux otherwise start it normally under Windows the 'fork' flag may deactivate the forking if it is set to False ''' #UNIX/LINUX: FORK if fork: try: #Fork and commit suicide if os.fork(): sys.exit(0) #What to do in parent process else: os.setsid() sys.stdin = open('/dev/null') sys.stdout = open('/dev/null', 'w') sys.stderr = open('/dev/null', 'w') cbk() #WINDOWS: JUST RUN except AttributeError: cbk() #PLAIN, NORMAL RUN else: cbk() def whateverFunctionToFork(): pass tryToFork(whateverFunctionToFork, True) [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Python
[2.4.2/Linux] Getting Python to fork?
Top