Boston Linux & Unix (BLU) Home | Calendar | Mail Lists | List Archives | Desktop SIG | Hardware Hacking SIG
Wiki | Flickr | PicasaWeb | Video | Maps & Directions | Installfests | Keysignings
Linux Cafe | Meeting Notes | Blog | Linux Links | Bling | About BLU

BLU Discuss list archive


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Daemon question



On Friday 10 February 2006 4:08 pm, David Kramer wrote:
> I have a program that I want to run in the background from the
> /etc/init.d scripts.  I copied another init.d script and modified it, and
> it runs the app, but doesn't put it in the background.  The
> /etc/init.d/myapp script continues to run.
>
> Isn't that the whole point of the daemon function in functions? To put
> the application in the background?
>
> For the record, this is on FC4.

Did you specify daemon in the script:
daemon $myprog $OPTIONS

(In SuSE, it would be:
startproc $myprog $OPTIONS)

Also, you will find that most daemons have code such as:

pid_t mypid = fork();
if (mypid == -1) // error stuff here
else if (mypid > 0) // Parent process - time to exit
	exit(0);
/* The daemon is now running */

There is also a sigaction to set a signal so the parent does not become a 
zombie (I think SIGCHILD). I don't have time right now to find that code, 
but you should be able to track it down. The reason for this code is to 
force it to have a parent process id==1. 

-- 
Jerry Feldman <gaf at blu.org>
Boston Linux and Unix user group
http://www.blu.org PGP key id:C5061EA9
PGP Key fingerprint:053C 73EC 3AC1 5C44 3E14 9245 FB00 3ED5 C506 1EA9




BLU is a member of BostonUserGroups
BLU is a member of BostonUserGroups
We also thank MIT for the use of their facilities.

Valid HTML 4.01! Valid CSS!



Boston Linux & Unix / webmaster@blu.org