Discussion Locked

Putting C code as Daemon in rc.d

0 helpful
2 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.
I have designed a pinging program in c language which is going to act as a daemon how do i put it in daemon so that it runs everytime i boot up the system

2 replies

by toivo talikka

I cannot give advice about your program written in c, but once you have got it working, I believe you need to write a shellscript with functions like start, stop and restart which call your program with the correct parameters expected by your program. These scripts are stored in /etc/rc.d/init.d. Have a look at them and you will find some you can base your script on.

For each runlevel, 0 to 6, go to the corresponding directory rc0.d - rc6.d and create a link pointing to your script in init.d. Look at the naming standard in the directory and the sequence in which you want to start or stop your script in relation to other services in the system

Study the script /etc/rc.d/rc to see how it controls the runlevel changes, first running all the KILL scripts K00... - K99... and then all the START scripts S00... - S99...

However, if you want to run your program just once, the best place to launch it is from /etc/rc.d/rc.local.

by nico baggus

You can also enter it into the inittab just like
the getty tools allready there.
Or as a runonce entry if restart is not needed.

man inittab should provide more info there.

This discussion is closed to new replies.