Current daemonize() function of cleanerd call _exit(2) only once during its process of becoming a daemon process. But in the linux environment, a daemon process should call _exit(2) twice for ensuring not being a session leader. If a process don't do that, unexpected SIGHUP can be sent to the process (though it happens rarely). The signal would be confusing event for cleanerd of nilfs. This patch removes this potential problem. Signed-off-by: Hitoshi Mitake <mitake.hitoshi@xxxxxxxxxxxxx> --- sbin/cleanerd/cleanerd.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/sbin/cleanerd/cleanerd.c b/sbin/cleanerd/cleanerd.c index 26067bd..edfa083 100644 --- a/sbin/cleanerd/cleanerd.c +++ b/sbin/cleanerd/cleanerd.c @@ -676,6 +676,16 @@ static int daemonize(int nochdir, int noclose, int nofork) /* umask(0); */ + /* for ensuring I'm not a session leader */ + if (!nofork) { + pid = fork(); + if (pid < 0) + return -1; + else if (pid != 0) + /* parent */ + _exit(0); + } + if (!nochdir && (chdir(ROOTDIR) < 0)) return -1; -- 1.8.1.2 -- To unsubscribe from this list: send the line "unsubscribe linux-nilfs" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html