[Tutor] Python Daemon

Pedro Diaz Jimenez pdiaz88@terra.es
Mon, 12 Mar 2001 01:34:32 +0100


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi, 

Well, the distinction between daemon and background proccess is conceptual. A 
daemon, per definition, is a background proccess. But a background proccess 
doesn't have to be a daemon. Tipically a daemon will provide some service, 
eg: telnet daemon (remote logins), ftp daemon (file transfer service), etc..

On the other hand, Remco Gerlich proposed some steps that a well designed 
daemon will do. I agree with Remco, and I would also propose to setuid () the 
daemon to nobody/nogroup for security reasons if you can

Cheers
Pedro

On Monday 12 March 2001 01:50, Tim Johnson wrote:
> 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
>
> _______________________________________________
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.0.1 (GNU/Linux)
Comment: For info see http://www.gnupg.org

iD8DBQE6rBmYnu53feEYxlERAhjPAJ93Ssk2KmE3hqxU9Hc926bseanAYACfcNeC
m/6u9VofcPPyUPgBMMRzzbY=
=WB/f
-----END PGP SIGNATURE-----