LinuxQuestions.org
Visit the LQ Articles and Editorials section
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Debian
User Name
Password
Debian This forum is for the discussion of Debian Linux.

Notices

Reply
 
Search this Thread
Old 02-13-2013, 04:07 PM   #1
Abscissa256
Member
 
Registered: Aug 2011
Posts: 67

Rep: Reputation: Disabled
Set up app as an init.d daemon, but it isn't running in background and stdout isn't blocked


I'm fairly new to linux daemons (doing this on Debian 6), and I have a custom HTTP server I want to set up to run as a daemon.

I copied and modified /etc/init.d/skeleton appropriately, and my program does run when I do "service myapp start". BUT it runs in the foreground and also stdin/stdout are still connected to my terminal. Is there a simple way to fix that without modifying the app, or is having the app itself disconnect its own stdin/out/err and then go into the background really the only way to do this?

Last edited by Abscissa256; 02-13-2013 at 04:08 PM.
 
Old 02-14-2013, 12:48 AM   #2
Abscissa256
Member
 
Registered: Aug 2011
Posts: 67

Original Poster
Rep: Reputation: Disabled
Ok, I think I figured it out. In my daemon's init.d script (ie from the skeleton file), inside the do_start() function, there are two calls to "start-stop-daemon". It seems I just needed to add the arguments "--background" and "--make-pidfile" to both of them. Seems to work fine now. Although I understand that if my daemon did any forking, then this would *not* work. Fortunately it doesn't fork on its own, so this seems to work.
 
  


Reply


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 Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Handling stdin and stdout in a daemon inakizi Programming 4 12-12-2007 11:13 PM
Running a program as a background daemon? Vor Kragresh Slackware 8 04-20-2007 10:48 AM
Running an app in background mode Naikon Linux - Newbie 4 08-30-2006 04:23 PM
how to set workspace when running an app evian Linux - General 1 08-17-2003 04:18 PM
stdout for a background process GOLDF1NG3R Linux - General 3 11-14-2001 01:10 PM


All times are GMT -5. The time now is 11:52 AM.

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