KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
I am trying to spawn a django process that lives on after the calling script died. But I need it's PID. So I wrote the following code: def runserver(): print("START PID: " + str(os.getpid())) pid = os.fork() if pid == 0: #cmd = "/usr/bin/env python manage.py runserver 0.0.0.0:2869" print("IN THE CHILD PID: " + str(os.getpid())) os.execvp("python", ["", "manage.py", "runserver", "0.0.0.0:2869"]) else: print("PARENT PID: " + str(os.getpid())) print("CHILD PID: " + str(pid)) updatepid("runserver", pid) This gives me the following output: START PID: 13019 PARENT PID: 13019 CHILD PID: 13020 IN THE CHILD PID: 13020 But now when I check the live processes: > ps aux | grep python | grep -v grep sandro 13031 0.4 0.3 296080 23756 pts/2 Sl 22:14 0:01 /home/sandro/.virtualenvs/polling/bin/python2.7 manage.py runserver 0.0.0.0:2869 The pid changed! What on earth is going on???
Tags (comma-separated)
Save Edits
Cancel