[Tutor] Python Daemon
Tim Johnson
tim@johnsons-web.com
Sun, 11 Mar 2001 15:50:00 -0900
Hi Thanks to Pedro.....
I used his coding suggestion as per below:
#!/usr/bin/python
import os
import sys
import time
PID = os.fork()
if PID != 0:
print "shutting down parent process:",PID
sys.exit()
else:
#print "Child still here"
time.sleep(20)
#print "Child exiting"
sys.exit()
#####################################
Now when I run this from a gnome-terminal window,
it operates *as -advertised*
if I type ps from that window, during the time that it remains installed,
I see something like this:
[tim@shecom sem2]$ python daemontest.py
shutting down parent process: 12234
[tim@shecom sem2]$ ps
PID TTY TIME CMD
11995 pts/2 00:00:00 bash
12234 pts/2 00:00:00 python # yo!! There it is
12235 pts/2 00:00:00 ps
# if at the same time, I go to another terminal and query processes
# this is what I see:
[tim@shecom tim]$ ps
PID TTY TIME CMD
12228 pts/1 00:00:00 bash
12236 pts/1 00:00:00 ps
# Now, my questions are :
Did I really create a daemon or did I just create a background process?
If I did create the daemon, how do I verify that?
Thanks
Not only am I just getting the hang of Python, I new to Linux as well.
:>)
Regards
--
Tim Johnson
-----------
"Of all manifestations of power,
restraint impresses the most."
-Thucydides