Solved

Creating a Daemon

Posted on 1998-11-09
4
284 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

I. Introduction There's an interesting discussion going on now in an Experts Exchange Group — Attachments with no extension (http://www.experts-exchange.com/discussions/210281/Attachments-with-no-extension.html). This reminded me of questions tha…
In the first part of this tutorial we will cover the prerequisites for installing SQL Server vNext on Linux.
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.:
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

731 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