aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/pidfile.c3
-rw-r--r--src/wydawca.c14
2 files changed, 10 insertions, 7 deletions
diff --git a/src/pidfile.c b/src/pidfile.c
index afbcb87..4e178db 100644
--- a/src/pidfile.c
+++ b/src/pidfile.c
@@ -33,7 +33,7 @@ check_pidfile ()
if (fp)
{
- unsigned long pid;
+ unsigned long pid = -1;
if (fscanf (fp, "%lu\n", &pid) != 1)
{
logmsg (LOG_ERR, _("malformed pidfile %s"), pidfile);
@@ -84,7 +84,6 @@ check_pidfile ()
}
fprintf (fp, "%lu\n", (unsigned long) getpid ());
fclose (fp);
- atexit (remove_pidfile);
}
diff --git a/src/wydawca.c b/src/wydawca.c
index f02ac99..d210717 100644
--- a/src/wydawca.c
+++ b/src/wydawca.c
@@ -275,15 +275,19 @@ extern int reconfigure;
void
wydawca_daemon ()
{
- check_pidfile ();
-
- if (!foreground && daemon (0, 0))
+ if (!foreground)
{
- logmsg (LOG_ERR, "%s", strerror (errno));
- exit (EX_OSERR);
+ if (daemon (0, 0))
+ {
+ logmsg (LOG_ERR, "%s", strerror (errno));
+ exit (EX_OSERR);
+ }
+ logmsg (LOG_NOTICE, _("daemon launched"));
}
+ check_pidfile ();
wydawca_listener ();
+ remove_pidfile ();
}

Return to:

Send suggestions and report system problems to the System administrator.