Solved

Creating a Daemon

Posted on 1998-11-09
4
278 Views
Last Modified: 2010-04-20
I need to make a process into a daemon either through the command line or programmatically.  (command line, preferred)

0
Comment
Question by:dpeng
4 Comments
 
LVL 2

Accepted Solution

by:
harrys earned 50 total points
ID: 1638458
from the comandline you could start it with
daemon&
which pushes it to the background.
in a program you would call fork() which starts a childprocess, then  inside the child  close the  stdin/stdout/stderr filehandles (see the manualpage of fork for details how
to detect who the child is..) and the child is you new daemon. inside the parent just
terminate the process.

0
 

Expert Comment

by:overcode
ID: 1638459
Linux Journal ran an article on daemons a while back, complete with code samples. It might be available on their web site.

-Reeves
0
 
LVL 2

Expert Comment

by:benten
ID: 1638460
What do you mean by a daemon?  Most programs that are considered daemons first fork a new process, orphan the child (by having the parent exit), close all the file descriptors and reset the session ids.
0
 

Author Comment

by:dpeng
ID: 1638461
Alright I'll try it out.
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Suggested Solutions

rdate is a Linux command and the network time protocol for immediate date and time setup from another machine. The clocks are synchronized by entering rdate with the -s switch (command without switch just checks the time but does not set anything). …
How many times have you wanted to quickly do the same thing to a list but found yourself typing it again and again? I first figured out a small time saver with the up arrow to recall the last command but that can only get you so far if you have a bi…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now