projects
/
paraslash.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Improve daemon_open_log_or_die().
[paraslash.git]
/
daemon.c
diff --git
a/daemon.c
b/daemon.c
index e47639bc42864cc4881d5992bb567e902f4752ac..49d2e1007fcf92c99c511fbcadbe0f461a05638d 100644
(file)
--- a/
daemon.c
+++ b/
daemon.c
@@
-234,15
+234,18
@@
void daemon_close_log(void)
*/
void daemon_open_log_or_die(void)
{
*/
void daemon_open_log_or_die(void)
{
- daemon_close_log();
+ FILE *new_log;
+
if (!me->logfile_name)
return;
if (!me->logfile_name)
return;
-
me->logfile
= fopen(me->logfile_name, "a");
- if (!
me->logfile
) {
+
new_log
= fopen(me->logfile_name, "a");
+ if (!
new_log
) {
PARA_EMERG_LOG("can not open %s: %s\n", me->logfile_name,
strerror(errno));
exit(EXIT_FAILURE);
}
PARA_EMERG_LOG("can not open %s: %s\n", me->logfile_name,
strerror(errno));
exit(EXIT_FAILURE);
}
+ daemon_close_log();
+ me->logfile = new_log;
/* equivalent to setlinebuf(), but portable */
setvbuf(me->logfile, NULL, _IOLBF, 0);
}
/* equivalent to setlinebuf(), but portable */
setvbuf(me->logfile, NULL, _IOLBF, 0);
}