Creating a Linux Daemon

John Porter Simons sport at
Fri Dec 7 23:50:45 PST 2001

Hello Linxuers,
(Sorry if this got posted twice, not sure if I was successfully subscribed
to the list the first time...)

I've got a question that maybe someone could help me with. Say I've got a
simple C program that takes some data, processes it, and returns a result.
And I want to use this program in a server-side web script, but I don't
want to instantiate the program everytime it's needed, because it
maintains large data structures and it may be executed frequently. What I
want to do is load the program on startup like a daemon, and have it stay
in memory. The processing it does is pretty simple, so I don't think it
needs to fork worker threads, it could have a single process which loops
through any requests.

But I have no idea how to do this. I wouldn't know whether to use pipes or
FIFOs or signals or what... Does anyone know of a good book or web
resource that provides an example of how to do this? I'm guessing that on
startup, the program would write its process ID to a file somewhere, but I
don't know how, from PHP for example, I could send data to the process at
that ID, and how the program would know where to send the result.

Any help would be appreciated...


John Simons
sport at

More information about the Linux mailing list