Visit Jeremy's Blog.
Go Back > Forums > Linux Forums > Linux - General
User Name
Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place.


  Search this Thread
Old 03-20-2001, 08:22 PM   #1
Registered: Mar 2001
Location: Santa Maria CA USA
Distribution: RedHat 6.0 & RedHat 7.0
Posts: 36

Rep: Reputation: 15

Is there a command to start and stop deamons running on a system? Specificly, I have a program that I've written to run in the background, and I don't know how to start it as a deamon. Thanks in advance for info!
Old 03-20-2001, 10:45 PM   #2
Senior Member
Registered: Feb 2001
Location: Atlanta, GA
Distribution: Slackware
Posts: 1,823

Rep: Reputation: 121Reputation: 121
I'm assuming that the daemon process that you have written follows the basic rules:

1) fork and exit the parent
2) setsid()
3) chdir("/")
4) umask(0)

Once you program is written you can start it like any other process and it will disassociate itself from the controlling terminal. To kill it use 'kill'.

If you want to get fancy, you can write a script that will take start or stop as a parameter. If passed start it could start the process and the daemon could log its pid to a file. When stop was called it could call kill on the daemon's pid.

Old 03-21-2001, 04:22 PM   #3
Registered: Mar 2001
Location: Santa Maria CA USA
Distribution: RedHat 6.0 & RedHat 7.0
Posts: 36

Original Poster
Rep: Reputation: 15
That fixed it. I was missing the setsid and umask functions.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Userid's and Deamons RonV Linux - Newbie 2 04-29-2005 07:55 PM
Starting and stoping squid in Slackware 10 barjeesshees Linux - Networking 0 10-22-2004 05:19 AM
Stoping xwindows from starting embalmedlenin Debian 7 09-25-2003 11:56 PM
samba deamons PlatinumRik Linux - Networking 4 05-21-2003 01:25 PM
Stoping and starting apache tuly Linux - Networking 3 05-30-2001 11:05 AM > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 01:42 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration