LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 01-10-2005, 09:35 PM   #1
shadypalm88
LQ Newbie
 
Registered: Dec 2004
Location: Wisconsin, USA
Distribution: Debian
Posts: 3

Rep: Reputation: 0
Question Logging From Background


Hello everyone. I've been writing a server using Linux that has the capability to log information to a file. When I run the server in the foreground, this works properly. But when run in the background (through command & or a call to daemon()), nothing is logged. Logging to standard output works properly.

The app is written in C++ but is using C I/O (fprintf).

Is there something I'm missing regarding logging from a background process?
 
Old 01-24-2005, 10:56 PM   #2
shadypalm88
LQ Newbie
 
Registered: Dec 2004
Location: Wisconsin, USA
Distribution: Debian
Posts: 3

Original Poster
Rep: Reputation: 0
Reviving my own old thread...

Anyone have any ideas at all?
 
Old 02-12-2005, 05:43 AM   #3
webvandals
Member
 
Registered: Aug 2003
Posts: 105

Rep: Reputation: 15
I'm having the exact same problem.

Does *nobody* know the answer to this?

No logging, no email. Works perfectly unless I background it.
 
Old 02-12-2005, 09:37 AM   #4
freegianghu
Member
 
Registered: Oct 2004
Location: somewhere in the street
Distribution: Window$
Posts: 192

Rep: Reputation: 30
Quote:
Originally posted by webvandals
I'm having the exact same problem.

Does *nobody* know the answer to this?

No logging, no email. Works perfectly unless I background it.
It's caused daemon function had closed stdio, stdout and stderr . Try call daemon with second arg other than zero
Code:
daemon(0, 1)
Hope this help,
Giang Hu
 
Old 02-12-2005, 05:30 PM   #5
webvandals
Member
 
Registered: Aug 2003
Posts: 105

Rep: Reputation: 15
Thanks freegianghu. Is there any way to "daemonize" a simple script? In my case, it's actually a PHP script but running from the command line just like a Perl script.

Also, someone may find it helpful to note that I'm only experiencing this issue on my Debian box, my RH9 and CentOS 3.4 boxes run the script in the background just fine.
 
Old 02-13-2005, 10:34 AM   #6
freegianghu
Member
 
Registered: Oct 2004
Location: somewhere in the street
Distribution: Window$
Posts: 192

Rep: Reputation: 30
Quote:
Originally posted by webvandals
Thanks freegianghu. Is there any way to "daemonize" a simple script? In my case, it's actually a PHP script but running from the command line just like a Perl script.

Also, someone may find it helpful to note that I'm only experiencing this issue on my Debian box, my RH9 and CentOS 3.4 boxes run the script in the background just fine.
Why dont you try with:
Code:
script > script.log 2>&1 &
 
Old 01-20-2015, 02:14 PM   #7
chrisoman
LQ Newbie
 
Registered: Jan 2015
Location: Chile
Distribution: Debian
Posts: 5

Rep: Reputation: Disabled
Quote:
Originally Posted by webvandals View Post
Thanks freegianghu. Is there any way to "daemonize" a simple script? In my case, it's actually a PHP script but running from the command line just like a Perl script.

Also, someone may find it helpful to note that I'm only experiencing this issue on my Debian box, my RH9 and CentOS 3.4 boxes run the script in the background just fine.
I have been searching around about back ground processing, but my application is embedded systems. I came across libslack (http://libslack.org/) which I haven't used but apparently this is a set of macros that you can use to create deamons() from simple c++/c programs.

Maybe that'll help
 
  


Reply



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
Change background in solaris and Xterm background also EvilAngel Solaris / OpenSolaris 2 01-31-2005 11:25 AM
Background and Xterm transparent background EvilAngel Linux - General 1 01-31-2005 09:40 AM
how to run any binary in background - background process tej Linux - Newbie 1 08-16-2004 12:27 AM
trouble with background process and logging out successfully isaia Linux - Newbie 3 04-05-2004 12:03 AM
How do I change the background images when logging onto the Xserver? LinuxQuest01 Linux - General 4 06-18-2002 09:22 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 12:00 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration