Queryable Daemon

Michael Torrie torriem at gmail.com
Sun Aug 2 21:36:08 EDT 2009


Justin DeCell wrote:
> I was hoping for a little help with a project I'm working on. I'm  
> writing a daemon in python that I want to be queryable  (i.e. I should  
> be able to run foo -s and it will report some internal information  
> about the foo daemon if it's running) but I can't figure out a way get  
> information from that process from an external process. I was thinking  
> that there should be a way to open a file descriptor, have the daemon  
> write to that every so often and then have the query process just read  
> from that fd but it looks like on the process reading from an fd has  
> to be a child of the daemon for this to work. The only other way I  
> thought of would be to write to a file on disk every so often from the  
> daemon and just read the from the query process but it seems like  
> there should be a more elegant way to do this...

Most daemon programs I know of that do this use unix sockets.  The
socket is typically put in /tmp, or probably better in /var/run, or some
other appropriate place.  Often this is configurable in a config file
that both the daemon and the program or instance that checks the daemon
read.

Another possibility is shared memory segments.  I'm not sure how
security is done in this case.  Anyway, shared memory is a common IPC
mechanism.



More information about the Python-list mailing list