+ if (!lp_load(config_file, 1)) {
+ exit_cleanup(RERR_SYNTAX);
+ }
+
+ log_init();
+
+ rprintf(FINFO, "rsyncd version %s starting, listening on port %d\n", VERSION,
+ rsync_port);
+ /* TODO: If listening on a particular address, then show that
+ * address too. */
+
+ if (((pid_file = lp_pid_file()) != NULL) && (*pid_file != '\0')) {
+ char pidbuf[16];
+ int fd;
+ int pid = (int) getpid();
+ cleanup_set_pid(pid);
+ if ((fd = do_open(lp_pid_file(), O_WRONLY|O_CREAT|O_TRUNC,
+ 0666 & ~orig_umask)) == -1) {
+ cleanup_set_pid(0);
+ rsyserr(FLOG, errno, "failed to create pid file %s", pid_file);
+ exit_cleanup(RERR_FILEIO);
+ }
+ snprintf(pidbuf, sizeof(pidbuf), "%d\n", pid);
+ write(fd, pidbuf, strlen(pidbuf));
+ close(fd);
+ }
+