* [nfs-utils PATCH] close the syslog fd in daemon_init()
@ 2015-09-29 15:36 Scott Mayhew
2015-11-04 21:49 ` Steve Dickson
0 siblings, 1 reply; 2+ messages in thread
From: Scott Mayhew @ 2015-09-29 15:36 UTC (permalink / raw)
To: steved; +Cc: linux-nfs
Commit 7addf9d (cleanup daemonization code) added the following line to
mydaemon_init():
dup2(pipefds[1], 3);
If we've already called vsyslog() before the fork(), then chances are fd
3 was being used for the syslog socket. In that case the next vsyslog()
call will cause the data to appear on the read end of the pipe, causing
the parent to exit with a nonzero status. If systemd is running, it
will see the parent's nonzero exit status and will terminate the child
as well.
So just call closelog() to close the fd. The next call to vsyslog()
will open a new one if need be.
Signed-off-by: Scott Mayhew <smayhew@redhat.com>
---
support/nfs/mydaemon.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/support/nfs/mydaemon.c b/support/nfs/mydaemon.c
index 3391eff..701cfd9 100644
--- a/support/nfs/mydaemon.c
+++ b/support/nfs/mydaemon.c
@@ -122,6 +122,7 @@ daemon_init(bool fg)
dup2(tempfd, 0);
dup2(tempfd, 1);
dup2(tempfd, 2);
+ closelog();
dup2(pipefds[1], 3);
pipefds[1] = 3;
closeall(4);
--
1.9.3
^ permalink raw reply related [flat|nested] 2+ messages in thread* Re: [nfs-utils PATCH] close the syslog fd in daemon_init()
2015-09-29 15:36 [nfs-utils PATCH] close the syslog fd in daemon_init() Scott Mayhew
@ 2015-11-04 21:49 ` Steve Dickson
0 siblings, 0 replies; 2+ messages in thread
From: Steve Dickson @ 2015-11-04 21:49 UTC (permalink / raw)
To: Scott Mayhew; +Cc: linux-nfs
On 09/29/2015 11:36 AM, Scott Mayhew wrote:
> Commit 7addf9d (cleanup daemonization code) added the following line to
> mydaemon_init():
>
> dup2(pipefds[1], 3);
>
> If we've already called vsyslog() before the fork(), then chances are fd
> 3 was being used for the syslog socket. In that case the next vsyslog()
> call will cause the data to appear on the read end of the pipe, causing
> the parent to exit with a nonzero status. If systemd is running, it
> will see the parent's nonzero exit status and will terminate the child
> as well.
>
> So just call closelog() to close the fd. The next call to vsyslog()
> will open a new one if need be.
>
> Signed-off-by: Scott Mayhew <smayhew@redhat.com>
Committed... Actual this is the one I fixed the warning on...
steved.
> ---
> support/nfs/mydaemon.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/support/nfs/mydaemon.c b/support/nfs/mydaemon.c
> index 3391eff..701cfd9 100644
> --- a/support/nfs/mydaemon.c
> +++ b/support/nfs/mydaemon.c
> @@ -122,6 +122,7 @@ daemon_init(bool fg)
> dup2(tempfd, 0);
> dup2(tempfd, 1);
> dup2(tempfd, 2);
> + closelog();
> dup2(pipefds[1], 3);
> pipefds[1] = 3;
> closeall(4);
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2015-11-04 21:49 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-09-29 15:36 [nfs-utils PATCH] close the syslog fd in daemon_init() Scott Mayhew
2015-11-04 21:49 ` Steve Dickson
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).