diff --git a/lsyncd.c b/lsyncd.c index 8fd9df2..89233ca 100644 --- a/lsyncd.c +++ b/lsyncd.c @@ -1120,9 +1120,6 @@ l_configure(lua_State *L) * from this on log to configurated log end instead of * stdout/stderr */ running = true; - if (settings.pidfile) { - write_pidfile(L, settings.pidfile); - } if (!settings.nodaemon && !is_daemon) { if (!settings.log_file) { settings.log_syslog = true; @@ -1130,6 +1127,9 @@ l_configure(lua_State *L) logstring("Debug", "daemonizing now."); daemonize(L); } + if (settings.pidfile) { + write_pidfile(L, settings.pidfile); + } } else if (!strcmp(command, "nodaemon")) { settings.nodaemon = true; } else if (!strcmp(command, "logfile")) {