Commit 178295c6 authored by Niels Möller's avatar Niels Möller
Browse files

(main): Changed the behaviour of the --no-syslog

option. Now --daemon --no-syslog puts the process into the
background without the rest of the daemonic setup. These option
names should be changed to something more correct, but it is used
only be the testsuite.

Rev: src/lshd.c:1.123
parent 66819b5b
......@@ -808,30 +808,56 @@ int main(int argc, char **argv)
return EXIT_FAILURE;
}
if (options->daemonic && !options->no_syslog)
if (options->daemonic)
{
if (options->no_syslog)
{
/* Just put process into the background. --no-syslog is an
* inappropriate name */
switch (fork())
{
case 0:
/* Child */
/* FIXME: Should we create a new process group, close our tty
* and stdio, etc? */
trace("forked into background. New pid: %i.\n", getpid());
break;
case -1:
/* Error */
werror("background_process: fork failed (errno = %i): %z\n",
errno, STRERROR(errno));
break;
default:
/* Parent */
_exit(EXIT_SUCCESS);
}
}
else
{
#if HAVE_SYSLOG
set_error_syslog("lshd");
set_error_syslog("lshd");
#else /* !HAVE_SYSLOG */
werror("lshd: No syslog. Further messages will be directed to /dev/null.\n");
werror("lshd: No syslog. Further messages will be directed to /dev/null.\n");
#endif /* !HAVE_SYSLOG */
}
if (options->daemonic)
switch (daemon_init())
{
case 0:
werror("lshd: Spawning into background failed.\n");
return EXIT_FAILURE;
case DAEMON_INETD:
werror("lshd: spawning from inetd not yet supported.\n");
return EXIT_FAILURE;
case DAEMON_INIT:
case DAEMON_NORMAL:
break;
default:
fatal("Internal error\n");
}
switch (daemon_init())
{
case 0:
werror("lshd: Spawning into background failed.\n");
return EXIT_FAILURE;
case DAEMON_INETD:
werror("lshd: spawning from inetd not yet supported.\n");
return EXIT_FAILURE;
case DAEMON_INIT:
case DAEMON_NORMAL:
break;
default:
fatal("Internal error\n");
}
}
}
if (options->use_pid_file && !daemon_pidfile(options->pid_file))
{
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment