From 54bc7aaa8daecf9cfc227d90fc2ecc3ddb178786 Mon Sep 17 00:00:00 2001 From: lotodore Date: Sun, 9 Jan 2011 11:07:08 +0000 Subject: [PATCH] Do not use own "daemon(...)" function. --- pokerth_server.pro | 2 +- src/core/linux/daemon.c | 85 ----------------------------------------- 2 files changed, 1 insertion(+), 86 deletions(-) delete mode 100644 src/core/linux/daemon.c diff --git a/pokerth_server.pro b/pokerth_server.pro index a63bbaad..f8b30cca 100644 --- a/pokerth_server.pro +++ b/pokerth_server.pro @@ -179,7 +179,7 @@ win32 { !win32 { DEPENDPATH += src/net/linux/ src/core/linux - SOURCES += src/core/linux/daemon.c + SOURCES += SOURCES += src/core/linux/convhelper.cpp } diff --git a/src/core/linux/daemon.c b/src/core/linux/daemon.c deleted file mode 100644 index 454d8055..00000000 --- a/src/core/linux/daemon.c +++ /dev/null @@ -1,85 +0,0 @@ -/*************************************************************************** - * Copyright (C) 2007 by Lothar May * - * * - * This program is free software; you can redistribute it and/or modify * - * it under the terms of the GNU General Public License as published by * - * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * - * * - * This program is distributed in the hope that it will be useful, * - * but WITHOUT ANY WARRANTY; without even the implied warranty of * - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * - * GNU General Public License for more details. * - * * - * You should have received a copy of the GNU General Public License * - * along with this program; if not, write to the * - * Free Software Foundation, Inc., * - * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * - ***************************************************************************/ -#ifdef _WIN32 -#error This source code is not for Win32. -#endif - -#include -#include -#include -#include -#include -#include - - -#ifndef daemon - -int -daemon(int nochdir, int noclose) -{ - int maxfd, fd = 0; - - if (getppid() == 1) - return 0; /* run_as_daemon has already been called. */ - - switch (fork()) - { - case 0: /* The child process. */ - break; - case -1: /* Fork failed. */ - return -1; - default: /* Exit the parent. */ - _exit(0); - } - /* Now running the child (daemon). */ - - if (setsid() < 0) /* Obtain a new process group. */ - return -1; - - switch (fork()) - { - case 0: - break; - case -1: - return -1; - default: - _exit(0); - } - - - if (!nochdir) - chdir("/"); /* Change working directory. */ - - if (!noclose) - { - /* Close all open handles. */ - maxfd = sysconf(_SC_OPEN_MAX); - while (fd < maxfd) - close(fd++); - - /* Use /dev/null as stdin/stdout/stderr. */ - open("/dev/null", O_RDWR); - dup(0); - dup(0); - } - - return 0; -} - -#endif