Making a Unix daemon process (was: Forking into the background (Linux))

2012-12-23 Thread Ben Finney
Hans Mulder han...@xs4all.nl writes: On 24/12/12 01:50:24, Olive wrote: My goal is to write a script that 1) write something to stdout; then fork into the background, closing the stdout (and stderr, stdin) pipe. I have found this answer (forking - setsid - forking)

Re: Daemon process

2009-09-02 Thread Hendrik van Rooyen
On Wednesday 02 September 2009 05:57:02 Shan wrote: I have XML RPC Server listening on a port. This XML RPC Server works fine when i run it as foreground process. All the clients are able to connect with the XML RPC Server. But when i run it as daemon(not using . I am doing it in python way

Re: Daemon process

2009-09-01 Thread Gabriel Genellina
En Wed, 02 Sep 2009 00:57:02 -0300, Shan m.shanmugara...@gmail.com escribió: I have XML RPC Server listening on a port. This XML RPC Server works fine when i run it as foreground process. All the clients are able to connect with the XML RPC Server. But when i run it as daemon(not using . I am

Daemon process

2009-09-01 Thread Shan
I have XML RPC Server listening on a port. This XML RPC Server works fine when i run it as foreground process. All the clients are able to connect with the XML RPC Server. But when i run it as daemon(not using . I am doing it in python way only), then no clients are able to connect with the

Re: PEP 3143 and daemon process

2009-04-13 Thread Ben Finney
than making the *current program* become a daemon process. It implies nothing special about external interaction with that process; having a service channel for controlling a separate process isn't part of becoming a daemon. And now I know of python-daemon, python-ll-core (has a daemon module

Re: PEP 3143 and daemon process

2009-04-13 Thread Alfredo Deza
application and could not find anything quite like it. Note that, as described in PEP 3143, “daemonize a program” means nothing more than making the *current program* become a daemon process. It implies nothing special about external interaction with that process; having a service channel

Re: PID lockfile (was: PEP 3143: Standard daemon process library)

2009-03-26 Thread Ben Finney
(replying in ‘comp.lang.python’ for wider feedback on this issue) On 26-Mar-2009, Francis Irving wrote: On Thu, Mar 26, 2009 at 12:51:06AM +1100, Ben Finney wrote: The ‘python-daemon’ distribution includes a module, ‘daemon.pidlockfile’. The ‘daemon.pidlockfile.PIDLockFile’ class is

Re: PEP 3143: Standard daemon process library

2009-03-25 Thread Ben Finney
Ben Finney ben+pyt...@benfinney.id.au writes: I've submitted PEP 3143 URL:http://www.python.org/dev/peps/pep-3143/ to meet this need, and have re-worked an existing library into a new ‘python-daemon’ URL:http://pypi.python.org/pypi/python-daemon/ library, the reference implementation. Now

Re: PEP 3143: Standard daemon process library

2009-03-24 Thread Jean-Paul Calderone
as easily done *after* the program achieves a daemon process? That depends. If you mean that one can ignore the uid and gid setting features of the proposed library so that they are not changed during daemonization and then make the appropriate calls from the application afterwards, then yes

Re: PEP 3143: Standard daemon process library

2009-03-24 Thread Floris Bruynooghe
On Mar 21, 11:06 pm, Ben Finney ben+pyt...@benfinney.id.au wrote: Floris Bruynooghe floris.bruynoo...@gmail.com writes: Had a quick look at the PEP and it looks very nice IMHO. Thank you. I hope you can try the implementation and report feedback on that too. One of the things that might

Re: PEP 3143: Standard daemon process library

2009-03-24 Thread Ben Finney
complex. Isn't setting the EUID and EGID something that is just as easily done *after* the program achieves a daemon process? That depends. If you mean that one can ignore the uid and gid setting features of the proposed library so that they are not changed during daemonization

Re: PEP 3143: Standard daemon process library

2009-03-23 Thread Ben Finney
out user shells. That sounds rather more specific than is needed for the generic library being proposed here. I'm wary of adding features to an API that is already quite complex. Isn't setting the EUID and EGID something that is just as easily done *after* the program achieves a daemon process

Re: PEP 3143: Standard daemon process library

2009-03-21 Thread Ben Finney
Floris Bruynooghe floris.bruynoo...@gmail.com writes: Had a quick look at the PEP and it looks very nice IMHO. Thank you. I hope you can try the implementation and report feedback on that too. One of the things that might be interesting is keeping file descriptors from the logging module

Re: PEP 3143: Standard daemon process library

2009-03-21 Thread Ben Finney
Jean-Paul Calderone exar...@divmod.com writes: The biggest shortcoming seems to be a complete lack of unit tests. A full unit test suite is in the source distribution's ‘tests/’ directory. You can run it with ‘python ./setup.py test’. A quick skim of the code suggests that part of it don't

Re: PEP 3143: Standard daemon process library

2009-03-21 Thread Jean-Paul Calderone
On Sun, 22 Mar 2009 10:19:58 +1100, Ben Finney ben+pyt...@benfinney.id.au wrote: Jean-Paul Calderone exar...@divmod.com writes: The biggest shortcoming seems to be a complete lack of unit tests. A full unit test suite is in the source distribution's ‘tests/’ directory. You can run it with

PEP 3143: Standard daemon process library (was: Writing a well-behaved daemon)

2009-03-20 Thread Ben Finney
and specification. One point to note: This is only intended to address the task of a program transforming *itself* into a daemon process. If you want to spawn off *extra* processes and manage them through a “service” channel, you want something this spec was never meant to cover. You may be interested

Re: PEP 3143: Standard daemon process library

2009-03-20 Thread Ben Finney
I need wider testing and scrutiny of the implementation and specification. PEP: 3143 Title: Standard daemon process library Version: $Revision: 1.1 $ Last-Modified: $Date: 2009-03-19 12:51 $ Author:Ben Finney ben+pyt...@benfinney.id.au Status

Re: PEP 3143: Standard daemon process library (was: Writing a well-behaved daemon)

2009-03-20 Thread Jean-Paul Calderone
On Fri, 20 Mar 2009 20:58:58 +1100, Ben Finney ben+pyt...@benfinney.id.au wrote: Ben Finney b...@benfinney.id.au writes: Writing a Python program to become a Unix daemon is relatively well-documented: there's a recipe for detaching the process and running in its own process group. However,

Re: PEP 3143: Standard daemon process library

2009-03-20 Thread Jean-Paul Calderone
On Fri, 20 Mar 2009 21:47:00 +1100, Ben Finney bignose+hates-s...@benfinney.id.au wrote: [snip] Somewhat by accident I noticed this other part of the PEP: Other Python daemon implementations that differ from this PEP: [snip] * Twisted [twisted]_ includes, perhaps unsurprisingly, an

Re: PEP 3143: Standard daemon process library (was: Writing a well-behaved daemon)

2009-03-20 Thread Floris Bruynooghe
On Mar 20, 9:58 am, Ben Finney ben+pyt...@benfinney.id.au wrote: Ben Finney b...@benfinney.id.au writes: Writing a Python program to become a Unix daemon is relatively well-documented: there's a recipe for detaching the process and running in its own process group. However, there's much

writing a message to the terminal in a daemon process

2008-03-23 Thread bharath venkatesh
hi, i created a daemon process using the following code import os import sys # Default daemon parameters. # File mode creation mask of the daemon. UMASK = 0 # Default working directory for the daemon. WORKDIR = / # Default maximum for the number of available file descriptors. MAXFD

Re: pySerial in a daemon process

2007-08-27 Thread Lawrence D'Oliveiro
In message [EMAIL PROTECTED], paul wrote: Before I had posted this question first thing I did was to look at / dev/ttyS0, and indeed the group is dialout (gid=20)... What are the full protections on the serial port? That is, can you post the output of ls -l /dev/ttyS0 please? --

pySerial in a daemon process

2007-08-26 Thread paul
I am writing a daemon process that reads data from the serial port / dev/ttyS0. I am using pyserial the method for setting up a daemon described in Chris' Python Page (http://homepage.hispeed.ch/py430/ python/) on an Ubuntu linux pc. Everything works great EXCEPT... in the daemon script

Re: pySerial in a daemon process

2007-08-26 Thread Bjoern Schliessmann
paul wrote: If I put these back in and try to run the daemon, the script fails when I try to connect to the serial port, with this error: serial.serialutil.SerialException: Could not open port: [Errno 13] Permission denied: '/dev/ttyS0' Did you check the permissions on this file? Often you

Re: pySerial in a daemon process

2007-08-26 Thread paul
On Aug 26, 5:20 pm, Bjoern Schliessmann usenet- [EMAIL PROTECTED] wrote: paul wrote: If I put these back in and try to run the daemon, the script fails when I try to connect to the serial port, with this error: serial.serialutil.SerialException: Could not open port: [Errno 13] Permission

Re: Making a non-root daemon process

2007-03-24 Thread Ben Finney
Ben Finney [EMAIL PROTECTED] writes: Hmm. I typed the example program in as a simplified version of what I'm doing; but didn't actually *run* it. When I do run it, I get no exception, as you say. Now I'll have to find out what significant difference there is between my failing code and this

Re: Making a non-root daemon process

2007-03-23 Thread Leo Kislov
On Mar 22, 11:19 pm, Ben Finney [EMAIL PROTECTED] wrote: Howdy all, For making a Python program calve off an independent daemon process of itself, I found Carl J. Schroeder's recipe in the ASPN Python Cookbook. URL:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731

Re: Making a non-root daemon process

2007-03-23 Thread Ben Finney
Leo Kislov [EMAIL PROTECTED] writes: On Mar 22, 11:19 pm, Ben Finney [EMAIL PROTECTED] wrote: The problem I'm having is that 'os.setsid()' fails with 'OSError: [Errno 1] Operation not permitted' unless I run the program as the root user. This isn't a program that I want necessarily running

Making a non-root daemon process

2007-03-22 Thread Ben Finney
Howdy all, For making a Python program calve off an independent daemon process of itself, I found Carl J. Schroeder's recipe in the ASPN Python Cookbook. URL:http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 This is a thorough approach, and I'm cribbing a simpler process from

Re: Creating a daemon process in Python

2007-02-23 Thread Nick Craig-Wood
Eirikur Hallgrimsson [EMAIL PROTECTED] wrote: def daemonize(): if (not os.fork()): # get our own session and fixup std[in,out,err] os.setsid() sys.stdin.close() sys.stdout = NullDevice() sys.stderr = NullDevice() That doesn't close the

Re: Creating a daemon process in Python

2007-02-23 Thread Jean-Paul Calderone
On Fri, 23 Feb 2007 08:30:07 -0600, Nick Craig-Wood [EMAIL PROTECTED] wrote: Eirikur Hallgrimsson [EMAIL PROTECTED] wrote: [snip] if (not os.fork()): # hang around till adopted by init ppid = os.getppid() while (ppid != 1):

Re: Creating a daemon process in Python

2007-02-23 Thread Eirikur Hallgrimsson
I didn't actually write this module. I believe I found it in a discussion in ASPN at Active State. Thanks for the input, and when I get a chance I will try these alternate approaches. This module has been working fine for me as is--so far. Eirikur --

Re: Creating a daemon process in Python

2007-02-22 Thread [EMAIL PROTECTED]
Thanks all, I understood there is no shortcut function like BSD daemon(). I'll do it manually using examples from cookbook... On 2月22日, 午前1:41, Benjamin Niemann [EMAIL PROTECTED] wrote: Hello, Sakagami Hiroki wrote: What is the easiest way to create a daemon process in Python? Google

Re: Creating a daemon process in Python

2007-02-22 Thread Grant Edwards
On 2007-02-22, [EMAIL PROTECTED] [EMAIL PROTECTED] wrote: I understood there is no shortcut function like BSD daemon(). I'll do it manually using examples from cookbook... Sure would be nice if somebody posted one. ;) -- Grant Edwards grante Yow! Oh, I get

Re: Creating a daemon process in Python

2007-02-22 Thread Joshua J. Kugler
Benjamin Niemann wrote: What is the easiest way to create a daemon process in Python? Google says I should call fork() and other system calls manually, but is there no os.daemon() and the like? You could try http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 Also, more

Creating a daemon process in Python

2007-02-21 Thread Sakagami Hiroki
Hi, What is the easiest way to create a daemon process in Python? Google says I should call fork() and other system calls manually, but is there no os.daemon() and the like? Regards, -- Sakagami Hiroki -- http://mail.python.org/mailman/listinfo/python-list

Re: Creating a daemon process in Python

2007-02-21 Thread Benjamin Niemann
Hello, Sakagami Hiroki wrote: What is the easiest way to create a daemon process in Python? Google says I should call fork() and other system calls manually, but is there no os.daemon() and the like? You could try http://aspn.activestate.com/ASPN/Cookbook/Python/Recipe/278731 HTH

Re: Creating a daemon process in Python

2007-02-21 Thread Eirikur Hallgrimsson
Sakagami Hiroki wrote: Hi, What is the easiest way to create a daemon process in Python? I find that this works great. I just pasted my copy, I think you can find it via Google. Eirikur # Daemon Module - basic facilities for becoming a daemon process # By Coy Krill # Combines ideas from

Re: Creating a daemon process in Python

2007-02-21 Thread garrickp
On Feb 21, 9:33 am, Eirikur Hallgrimsson [EMAIL PROTECTED] wrote: Sakagami Hiroki wrote: What is the easiest way to create a daemon process in Python? I've found it even easier to use the built in threading modules: import time t1 = time.time() print t_poc.py called at, t1 import threading

Re: Creating a daemon process in Python

2007-02-21 Thread Benjamin Niemann
[EMAIL PROTECTED] wrote: On Feb 21, 9:33 am, Eirikur Hallgrimsson [EMAIL PROTECTED] wrote: Sakagami Hiroki wrote: What is the easiest way to create a daemon process in Python? I've found it even easier to use the built in threading modules: import time t1 = time.time() print

Re: Creating a daemon process in Python

2007-02-21 Thread garrickp
On Feb 21, 3:34 pm, Benjamin Niemann [EMAIL PROTECTED] wrote: That's not a daemon process (which are used to execute 'background services' in UNIX environments). I had not tested this by running the script directly, and in writing a response, I found out that the entire interpreter closed when

Re: Python daemon process

2006-08-29 Thread Thomas Dybdahl Ahle
, but in java, you could make a process a daemon process, and it would only run as long as the real processes ran. I think this is a better way to stop gnuchess, as you are 100% sure, that it'll stop. Can you do this with popen? -- Thomas -- http://mail.python.org/mailman/listinfo/python-list

Re: Python daemon process

2006-08-27 Thread Paolo Pantaleo
2006/8/26, Thomas Dybdahl Ahle [EMAIL PROTECTED]: Hi, I'm writing a program, using popen4(gnuchess), The problem is, that gnuchess keeps running after program exit. I know about the atexit module, but in java, you could make a process a daemon process, and it would only run as long

Python daemon process

2006-08-26 Thread Thomas Dybdahl Ahle
Hi, I'm writing a program, using popen4(gnuchess), The problem is, that gnuchess keeps running after program exit. I know about the atexit module, but in java, you could make a process a daemon process, and it would only run as long as the real processes ran. I think this is a better way to stop

Re: Python daemon process

2006-08-26 Thread faulkner
a daemon process, and it would only run as long as the real processes ran. I think this is a better way to stop gnuchess, as you are 100% sure, that it'll stop. Can you do this with popen? -- Thomas -- http://mail.python.org/mailman/listinfo/python-list