Lines Matching full:daemon

2  * daemon/unbound.c - main program for unbound DNS resolver daemon.
40 * Main program to start the DNS resolver daemon.
49 #include "daemon/daemon.h"
50 #include "daemon/remote.h"
146 printf(" start unbound daemon DNS resolver.\n"); in usage()
301 apply_settings(struct daemon* daemon, struct config_file* cfg, in apply_settings() argument
311 daemon_apply_cfg(daemon, cfg); in apply_settings()
434 /* use POSIX daemon(3) function */ in detach()
435 if(daemon(1, 0) != 0) in detach()
436 fatal_exit("daemon failed: %s", strerror(errno)); in detach()
484 setup_sslctxs(struct daemon* daemon, struct config_file* cfg) in setup_sslctxs() argument
487 if(!(daemon->rc = daemon_remote_create(cfg))) in setup_sslctxs()
499 (void)setup_listen_sslctx(&daemon->listen_dot_sslctx, 1, 0, cfg); in setup_sslctxs()
502 (void)setup_listen_sslctx(&daemon->listen_doh_sslctx, 0, 1, cfg); in setup_sslctxs()
507 if(!(daemon->listen_quic_sslctx = quic_sslctx_create( in setup_sslctxs()
514 if(!(daemon->connect_dot_sslctx = connect_sslctx_create(NULL, NULL, in setup_sslctxs()
518 (void)daemon;(void)cfg; in setup_sslctxs()
524 perform_setup(struct daemon* daemon, struct config_file* cfg, int debug_mode, in perform_setup() argument
534 if(!daemon_privileged(daemon)) in perform_setup()
548 (void)setup_sslctxs(daemon, cfg); in perform_setup()
572 daemon->pidfile = strdup(cfg->pidfile); in perform_setup()
573 else daemon->pidfile = fname_after_chroot(cfg->pidfile, in perform_setup()
575 if(!daemon->pidfile) in perform_setup()
585 checkoldpid(daemon->pidfile, pidinchroot); in perform_setup()
597 writepid(daemon->pidfile, getpid()); in perform_setup()
600 (void)daemon; in perform_setup()
641 if(daemon->pidfile && daemon->pidfile[0] && in perform_setup()
642 strncmp(daemon->pidfile, cfg->chrootdir, in perform_setup()
644 char* old = daemon->pidfile; in perform_setup()
645 daemon->pidfile = strdup(old+strlen(cfg->chrootdir)); in perform_setup()
647 if(!daemon->pidfile) in perform_setup()
650 daemon->chroot = strdup(cfg->chrootdir); in perform_setup()
651 if(!daemon->chroot) in perform_setup()
652 log_err("out of memory in daemon chroot dir storage"); in perform_setup()
711 daemon->cfgfile = strdup(*cfgfile); in perform_setup()
712 if(!daemon->cfgfile) in perform_setup()
713 fatal_exit("out of memory in daemon cfgfile strdup"); in perform_setup()
717 * Run the daemon.
728 struct daemon* daemon = NULL; in run_daemon() local
731 if(!(daemon = daemon_init())) in run_daemon()
733 while(!daemon->need_to_exit) { in run_daemon()
741 if(!config_read(cfg, cfgfile, daemon->chroot)) { in run_daemon()
750 apply_settings(daemon, cfg, cmdline_verbose, debug_mode); in run_daemon()
755 if(!daemon_open_shared_ports(daemon)) in run_daemon()
758 perform_setup(daemon, cfg, debug_mode, &cfgfile, need_pidfile); in run_daemon()
766 daemon_fork(daemon); in run_daemon()
770 daemon_cleanup(daemon); in run_daemon()
776 if(daemon->pidfile) { in run_daemon()
779 fd = open(daemon->pidfile, O_WRONLY | O_TRUNC in run_daemon()
787 unlink(daemon->pidfile); in run_daemon()
789 daemon_delete(daemon); in run_daemon()