How to create a Process with python?

L00PeR
7 years ago

0

Hi, I would like to know how to create a process with python that doesn’t stop when the terminal is closed.
I have tried with this code (This code creates the process correctly but dies when I close the terminal):
from multiprocessing import Process def test(): while 1: pass # This function is just an example -_- p = Process(target=test) p.start()

3replies
4voices
171views
Smyler [WHGhost]
7 years ago

0

I think you have to fork th current process using os.fork .

L00PeR
7 years ago

0

but how would be the code?
os.fork()
just that?

L00PeR
7 years ago

0

ok found the solution :)
Thaaanks :)

def test():  
   while 1:  
      pass  
newRef = os.fork()  
if newRef == 0:  
    test()  
2 replies have been removed
You must be logged in to reply to this discussion. Login
1 of 4

This site only uses cookies that are essential for the functionality of this website. Cookies are not used for tracking or marketing purposes.

By using our site, you acknowledge that you have read and understand our Privacy Policy, and Terms of Service.

Dismiss