Add a PID file.

merge-requests/1/head
Julien BLACHE 2008-04-10 16:39:06 +00:00
rodzic ce7efefec7
commit cbb3833dbe
2 zmienionych plików z 16 dodań i 3 usunięć

Wyświetl plik

@ -1,7 +1,7 @@
2008-04-10 Julien Blache <jb@jblache.org>
* frontend/saned.c: do not use daemon(), as it's a 4.4BSD/glibc
function; OS/2 for instance does not have it. Use an open-coded
equivalent.
equivalent. Add a PID file.
2008-04-06 Nicolas Martin <nicols-guest at users.alioth.debian.org>
* backend/pixma_mp150.c:

Wyświetl plik

@ -190,6 +190,7 @@ struct saned_child *children;
int numchildren;
#define SANED_CONFIG_FILE "saned.conf"
#define SANED_PID_FILE "/var/run/saned.pid"
#define SANED_SERVICE_NAME "sane-port"
#define SANED_SERVICE_PORT 6566
@ -2445,6 +2446,8 @@ run_standalone (int argc, char **argv)
int i;
int ret;
FILE *pidfile;
/* Unused in this function */
argc = argc;
argv = argv;
@ -2473,6 +2476,18 @@ run_standalone (int argc, char **argv)
exit (1);
}
DBG (DBG_WARN, "Now daemonized\n");
/* Write out PID file */
pidfile = fopen (SANED_PID_FILE, "w");
if (pidfile)
{
fprintf (pidfile, "%d", getpid());
fclose (pidfile);
}
else
DBG (DBG_ERR, "Could not write PID file: %s\n", strerror (errno));
chdir ("/");
dup2 (fd, STDIN_FILENO);
@ -2483,8 +2498,6 @@ run_standalone (int argc, char **argv)
setsid ();
DBG (DBG_WARN, "Now daemonized\n");
signal(SIGINT, sig_int_term_handler);
signal(SIGTERM, sig_int_term_handler);
}