All of lore.kernel.org
 help / color / mirror / Atom feed
From: Pablo Neira Ayuso <pablo@netfilter.org>
To: Ben Lentz <BLentz@channing-bete.com>
Cc: Netfilter Development Mailinglist <netfilter-devel@vger.kernel.org>
Subject: Re: conntrack accounting
Date: Sat, 05 Jan 2008 15:36:37 +0100	[thread overview]
Message-ID: <477F95F5.8070507@netfilter.org> (raw)
In-Reply-To: <477F928A.70206@channing-bete.com>

[-- Attachment #1: Type: text/plain, Size: 520 bytes --]

Ben Lentz wrote:
> Hmmm... file descriptors for STDIN, STDOUT, and STDERR should be closed,
> too... the setsid() detaches the controlling terminal but a terminal
> still hangs at logout after starting the daemon. A quick-and-dirty patch
> is attached, but there's probably a "better" way to do this.

I have applied a similar patch. I have also moved the initialization
before the daemonization so that the error messages that may occur are
still printed ;)

-- 
"Los honestos son inadaptados sociales" -- Les Luthiers

[-- Attachment #2: x --]
[-- Type: text/plain, Size: 1553 bytes --]

Index: src/main.c
===================================================================
--- src/main.c	(revisión: 7171)
+++ src/main.c	(copia de trabajo)
@@ -270,6 +270,18 @@
 	}
 	close(ret);
 
+	/*
+	 * initialization process
+	 */
+
+	if (init() == -1) {
+		close_log();
+		fprintf(stderr, "ERROR: conntrackd cannot start, please "
+				"check the logfile for more info\n");
+		unlink(CONFIG(lockfile));
+		exit(EXIT_FAILURE);
+	}
+
 	/* Daemonize conntrackd */
 	if (type == DAEMON) {
 		pid_t pid, sid;
@@ -287,23 +299,15 @@
 			exit(EXIT_FAILURE);
 		}
 
+		close(STDIN_FILENO);
+		close(STDOUT_FILENO);
+		close(STDERR_FILENO);
+
 		dlog(STATE(log), LOG_NOTICE, "-- starting in daemon mode --");
 	} else
 		dlog(STATE(log), LOG_NOTICE, "-- starting in console mode --");
 
 	/*
-	 * initialization process
-	 */
-
-	if (init() == -1) {
-		close_log();
-		fprintf(stderr, "ERROR: conntrackd cannot start, please "
-				"check the logfile for more info\n");
-		unlink(CONFIG(lockfile));
-		exit(EXIT_FAILURE);
-	}
-
-	/*
 	 * run main process
 	 */
 	run();
Index: ChangeLog
===================================================================
--- ChangeLog	(revisión: 7171)
+++ ChangeLog	(copia de trabajo)
@@ -29,6 +29,7 @@
 o minor irrelevant fixes for uncommon error paths and fix several typos
 o detach daemon from its terminal (Ben Lenitz <BLentz@channing-bete.com>)
 o obsolete `-S' option: Use information provided by the config file
+o daemonize conntrackd after initialization
 
 version 0.9.5 (2007/07/29)
 ------------------------------

  reply	other threads:[~2008-01-05 14:36 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-30  2:39 conntrack accounting Ben Lentz
2008-01-03 15:54 ` Pablo Neira Ayuso
2008-01-03 18:12   ` Ben Lentz
2008-01-04  3:25     ` Ben Lentz
2008-01-04 21:35       ` Ben Lentz
2008-01-05 12:39         ` Pablo Neira Ayuso
     [not found]       ` <477DA84A.3030304@channing-bete.com>
     [not found]         ` <477EAEF0.4000300@channing-bete.com>
2008-01-05 12:45           ` Pablo Neira Ayuso
2008-01-05 14:22             ` Ben Lentz
2008-01-05 14:36               ` Pablo Neira Ayuso [this message]
2008-01-05 16:24               ` Jan Engelhardt
2008-01-05 16:44               ` Pablo Neira Ayuso
2008-01-05 18:52                 ` Ben Lentz

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=477F95F5.8070507@netfilter.org \
    --to=pablo@netfilter.org \
    --cc=BLentz@channing-bete.com \
    --cc=netfilter-devel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.