On Sun, Mar 23, 2003 at 08:44:10PM -0800, !@#$%^&*() wrote:
Hey ALL,
I have a C executable, which I want to run as a Service just like "httpd" or "mysqld", I guess its called "DAEMON mode", how should I do this. I do not want to run it via CRON.
Any pointers, leads are greatly appreciated.
' like "httpd" or "mysqld" ' introduces the extra dimention of sockets.
If it's something like "crond", then there's no socket programming involved.
In either case, the common factor is fork() (and, maybe, exec ).
fork creates a child process, which can continue running. the parent can exit. The process thus goes into the background, and can serve requests or do something on its own.
The standard Steven's n/w prog. book contains a nice skeleton, wherein you can fill your own logic.
BTW, your subject talks about running scripts, but the content points to C executable code ...
hth.