Solved

Creating a Daemon

Posted on 1998-11-09
4
279 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

I am a long time windows user and for me it is normal to have spaces in directory and file names. Changing to Linux I found myself frustrated when I moved my windows data over to my new Linux computer. The problem occurs when at the command line.…
If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Learn several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:

914 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

16 Experts available now in Live!

Get 1:1 Help Now