kopia lustrzana https://gitlab.com/sane-project/backends
Replace daemon() with an open-coded equivalent.
rodzic
67ebd9576c
commit
ce7efefec7
|
@ -1,3 +1,8 @@
|
||||||
|
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.
|
||||||
|
|
||||||
2008-04-06 Nicolas Martin <nicols-guest at users.alioth.debian.org>
|
2008-04-06 Nicolas Martin <nicols-guest at users.alioth.debian.org>
|
||||||
* backend/pixma_mp150.c:
|
* backend/pixma_mp150.c:
|
||||||
Modifications for PIXMA MP970, to manage the CCD sensor
|
Modifications for PIXMA MP970, to manage the CCD sensor
|
||||||
|
|
|
@ -2441,7 +2441,7 @@ run_standalone (int argc, char **argv)
|
||||||
struct pollfd *fds = NULL;
|
struct pollfd *fds = NULL;
|
||||||
struct pollfd *fdp = NULL;
|
struct pollfd *fdp = NULL;
|
||||||
int nfds;
|
int nfds;
|
||||||
int fd;
|
int fd = -1;
|
||||||
int i;
|
int i;
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -2455,12 +2455,36 @@ run_standalone (int argc, char **argv)
|
||||||
{
|
{
|
||||||
DBG (DBG_MSG, "run_standalone: daemonizing now\n");
|
DBG (DBG_MSG, "run_standalone: daemonizing now\n");
|
||||||
|
|
||||||
if (daemon (0, 0) != 0)
|
fd = open ("/dev/null", O_RDWR);
|
||||||
|
if (fd < 0)
|
||||||
{
|
{
|
||||||
DBG (DBG_ERR, "FATAL ERROR: cannot daemonize: %s\n", strerror (errno));
|
DBG (DBG_ERR, "FATAL ERROR: cannot open /dev/null: %s\n", strerror (errno));
|
||||||
exit (1);
|
exit (1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ret = fork ();
|
||||||
|
if (ret > 0)
|
||||||
|
{
|
||||||
|
_exit (0);
|
||||||
|
}
|
||||||
|
else if (ret < 0)
|
||||||
|
{
|
||||||
|
DBG (DBG_ERR, "FATAL ERROR: fork failed: %s\n", strerror (errno));
|
||||||
|
exit (1);
|
||||||
|
}
|
||||||
|
|
||||||
|
chdir ("/");
|
||||||
|
|
||||||
|
dup2 (fd, STDIN_FILENO);
|
||||||
|
dup2 (fd, STDOUT_FILENO);
|
||||||
|
dup2 (fd, STDERR_FILENO);
|
||||||
|
|
||||||
|
close (fd);
|
||||||
|
|
||||||
|
setsid ();
|
||||||
|
|
||||||
|
DBG (DBG_WARN, "Now daemonized\n");
|
||||||
|
|
||||||
signal(SIGINT, sig_int_term_handler);
|
signal(SIGINT, sig_int_term_handler);
|
||||||
signal(SIGTERM, sig_int_term_handler);
|
signal(SIGTERM, sig_int_term_handler);
|
||||||
}
|
}
|
||||||
|
|
Ładowanie…
Reference in New Issue