From d610b481be48d9807e936592149ce6c51758ced1 Mon Sep 17 00:00:00 2001 From: Thibault Godouet Date: Sun, 13 Apr 2014 18:48:17 +0100 Subject: [PATCH] fixed minor bug in fcronsighup: no need to close() after fclose() on stream from fdopen() --- doc/en/changes.sgml | 3 +++ fcronsighup.c | 4 +++- fcrontab.c | 1 + 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/doc/en/changes.sgml b/doc/en/changes.sgml index a2f8b5e..8750ddb 100644 --- a/doc/en/changes.sgml +++ b/doc/en/changes.sgml @@ -23,6 +23,9 @@ A copy of the license is included in gfdl.sgml. fcrondyn -x no longer adds null characters at the end of the output. This would cause problems if the output was piped to something as grep. Thanks Dimitri Semitsoglou-Tsiapos for pointing this out. + + Fixed minor bug in fcronsighup resulting in log errors about closing the signal file + diff --git a/fcronsighup.c b/fcronsighup.c index 90bd86a..c4f248d 100644 --- a/fcronsighup.c +++ b/fcronsighup.c @@ -169,8 +169,10 @@ sig_daemon(void) sleep(sl); + /* also closes the underlying file descriptor fd: */ xfclose_check(&fp, sigfile); - xclose_check(&fd, sigfile); + /* also reset fd, now closed by xfclose_check(), to make it clear it is closed */ + fd = -1; if (remove(sigfile) < 0) error_e("Could not remove %s"); diff --git a/fcrontab.c b/fcrontab.c index 8f68462..2e29c3d 100644 --- a/fcrontab.c +++ b/fcrontab.c @@ -402,6 +402,7 @@ list_file(const char *file) while ((c = getc(f)) != EOF) putchar(c); + /* also closes the underlying file descriptor fd: */ xfclose_check(&f, file); } -- 2.47.3