Linux NILFS development
 help / color / mirror / Atom feed
From: Hitoshi Mitake <mitake.hitoshi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
Cc: mitake.hitoshi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org,
	Hitoshi Mitake
	<mitake.hitoshi-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
Subject: [PATCH nilfs-utils v2 1/4] cleanerd: ignore nofork option
Date: Mon,  6 Jan 2014 00:52:42 +0900	[thread overview]
Message-ID: <1388937165-32692-2-git-send-email-mitake.hitoshi@gmail.com> (raw)
In-Reply-To: <1388937165-32692-1-git-send-email-mitake.hitoshi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>

The nofork option aims to reduce call of fork(), but it is not
effective. This patch lets cleanerd ignore the option simply even if
it is passed.

Signed-off-by: Hitoshi Mitake <mitake.hitoshi-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
---
 sbin/cleanerd/cleanerd.c | 28 ++++++++++++----------------
 1 file changed, 12 insertions(+), 16 deletions(-)

diff --git a/sbin/cleanerd/cleanerd.c b/sbin/cleanerd/cleanerd.c
index e1f6a04..0b5bb70 100644
--- a/sbin/cleanerd/cleanerd.c
+++ b/sbin/cleanerd/cleanerd.c
@@ -113,7 +113,7 @@ do {						\
 const static struct option long_option[] = {
 	{"conffile", required_argument, NULL, 'c'},
 	{"help", no_argument, NULL, 'h'},
-	/* internal option for mount.nilfs2 only */
+	/* nofork option is obsolete. It does nothing even if passed */
 	{"nofork", no_argument, NULL, 'n'},
 	{"protection-period", required_argument, NULL, 'p'},
 	{"version", no_argument, NULL, 'V'},
@@ -691,20 +691,18 @@ static int oom_adjust(void)
 #define DEVNULL	"/dev/null"
 #define ROOTDIR	"/"
 
-static int daemonize(int nochdir, int noclose, int nofork)
+static int daemonize(int nochdir, int noclose)
 {
 	pid_t pid;
 
-	if (!nofork) {
-		pid = fork();
-		if (pid < 0)
-			return -1;
-		else if (pid != 0)
-			/* parent */
-			_exit(0);
-	}
+	pid = fork();
+	if (pid < 0)
+		return -1;
+	else if (pid != 0)
+		/* parent */
+		_exit(0);
 
-	/* child or nofork */
+	/* child */
 	if (setsid() < 0)
 		return -1;
 
@@ -1491,7 +1489,7 @@ int main(int argc, char *argv[])
 	char canonical[PATH_MAX + 2];
 	const char *dev, *dir;
 	char *endptr;
-	int status, nofork, c;
+	int status, c;
 #ifdef _GNU_SOURCE
 	int option_index;
 #endif	/* _GNU_SOURCE */
@@ -1499,7 +1497,6 @@ int main(int argc, char *argv[])
 	progname = (strrchr(argv[0], '/') != NULL) ?
 		strrchr(argv[0], '/') + 1 : argv[0];
 	conffile = NILFS_CLEANERD_CONFFILE;
-	nofork = 0;
 	status = 0;
 	protection_period = ULONG_MAX;
 	dev = NULL;
@@ -1520,8 +1517,7 @@ int main(int argc, char *argv[])
 			nilfs_cleanerd_usage(progname);
 			exit(0);
 		case 'n':
-			/* internal option for mount.nilfs2 only */
-			nofork = 1;
+			/* ignore nofork option, do nothing */
 			break;
 		case 'p':
 			protection_period = strtoul(optarg, &endptr, 10);
@@ -1568,7 +1564,7 @@ int main(int argc, char *argv[])
 		}
 	}
 
-	if (daemonize(0, 0, nofork) < 0) {
+	if (daemonize(0, 0) < 0) {
 		fprintf(stderr, "%s: %s\n", progname, strerror(errno));
 		exit(1);
 	}
-- 
1.8.1.2

--
To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2014-01-05 15:52 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-01-05 15:52 [PATCH nilfs-utils v2 0/4] rework daemonize() of cleanerd Hitoshi Mitake
     [not found] ` <1388937165-32692-1-git-send-email-mitake.hitoshi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-05 15:52   ` Hitoshi Mitake [this message]
     [not found]     ` <1388937165-32692-2-git-send-email-mitake.hitoshi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-05 17:19       ` [PATCH nilfs-utils v2 1/4] cleanerd: ignore nofork option Ryusuke Konishi
2014-01-05 15:52   ` [PATCH nilfs-utils v2 2/4] cleanerd: call _exit(2) twice for ensuring not being a session leader Hitoshi Mitake
     [not found]     ` <1388937165-32692-3-git-send-email-mitake.hitoshi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-05 17:20       ` Ryusuke Konishi
     [not found]         ` <20140106.022042.112826181.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-01-05 18:28           ` Ryusuke Konishi
     [not found]             ` <CAFPMYnH8LTD9ctZCSht5NZv6j1TZMfpCZh2pHyLO4wN-5dRDdw@mail.gmail.com>
     [not found]               ` <CAFPMYnH8LTD9ctZCSht5NZv6j1TZMfpCZh2pHyLO4wN-5dRDdw-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2014-01-06  3:53                 ` Hitoshi Mitake
     [not found]             ` <20140106.032857.373562363.konishi.ryusuke-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.org>
2014-01-07 21:19               ` Michael Conrad
2014-01-05 15:52   ` [PATCH nilfs-utils v2 3/4] mount: don't pass -n option to cleanerd Hitoshi Mitake
     [not found]     ` <1388937165-32692-4-git-send-email-mitake.hitoshi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-05 17:21       ` Ryusuke Konishi
2014-01-05 15:52   ` [PATCH nilfs-utils v2 4/4] man: remove a description of -n option Hitoshi Mitake
     [not found]     ` <1388937165-32692-5-git-send-email-mitake.hitoshi-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2014-01-05 17:22       ` Ryusuke Konishi

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=1388937165-32692-2-git-send-email-mitake.hitoshi@gmail.com \
    --to=mitake.hitoshi-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=linux-nilfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=mitake.hitoshi-Zyj7fXuS5i5L9jVzuh4AOg@public.gmane.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox