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.
Thanking in anticipation.
SP
__________________________________________________ Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com
You can start it at the system boot time by putting it in /etc/rc.d/rc.local.
CRON is used to execute jobs repeatedly and NOT to run daemon jobs.
Amitay.
On Mon, 2003-03-24 at 10:14, !@#$%^&*() 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.
Thanking in anticipation.
SP
Do you Yahoo!? Yahoo! Platinum - Watch CBS' NCAA March Madness, live on your desktop! http://platinum.yahoo.com
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.
!@#$%^&*() writes:
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.
man daemon. Googlize on it's use. If you want ot start the script at startup, maybe you can add an init script. Then u can run it as a service like httpd or mysqld.
Vinayak Hegde APGDST Student NCST-JUHU
!@#$%^&*() writes:
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.
You would want to read up man page for daemon(). In short, you'd need to fork() [parent 1], start a new session and make it the process leader using setsid(), realease the parent [parent 1] using fork() [parent 2] again, and then if you are using BDS pthreads, take care of stuff like umask, root directory (chdir ("/"). daemon() call would do the rest by closing the child fd's and then releasing the tty's. For details, google.
./h
On Mar 23, 2003 at 20:44, !@#$%^&*() wrote:
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 someone pointed out, see the Stevens Unix Network programming book for a daemon skeleton. Then read the rc scripts documentation (pointers in /etc/init.d or /etc/rc.d). Basically you want to fork, reset all signals, detach from controlling terminal, open sockets, close terminal sockets.... I'm not clear on the issues, but Stevens is.