Commit 95822d3a authored by Jean-Paul Saman's avatar Jean-Paul Saman

Forgot to close inherited file descriptors from the parent process. After...

Forgot to close inherited file descriptors from the parent process. After closing all standard filedescriptors stdin, stdout and stderr. The daemon makes sure that any message going to any of these dissapear into the bitbucket. If there is omething to tell, then use syslog.
parent 7f4ff861
......@@ -2,7 +2,7 @@
* daemon.cpp:
*-------------------------------------------------------------------------------
* (c)1999-2002 VideoLAN
* $Id: daemon.cpp,v 1.2 2002/10/07 15:01:22 sam Exp $
* $Id: daemon.cpp,v 1.3 2003/02/20 21:40:46 jpsaman Exp $
*
* Authors: Jean-Paul Saman <saman@natlab.research.philips.com>
*
......@@ -61,8 +61,7 @@ int C_Daemon::StartDaemon()
int C_Daemon::StopDaemon()
{
exit(1);
return -1;
return 0;
}
bool C_Daemon::isDaemon()
......@@ -109,11 +108,20 @@ void C_Daemon::DaemonCloseTerminal()
{
#ifndef _WIN32
int fileDesc = -1;
/*
* close all opened file descriptors we inherited from the parent process
* they are not needed anymore. Messages should be send to the syslog daemon
* instead.
*/
close(STDIN_FILENO);
close(STDOUT_FILENO);
close(STDERR_FILENO);
/*
* now we are in a new session and process
* group than process that started the
* daemon. We also have no controlling
* terminal */
* terminal
* */
chdir("/");
umask(0);
fileDesc = open("/dev/null", O_RDWR);/* stdin */
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment