Lines Matching refs:pidfile

151 	printf("-p	do not create a pidfile.\n");
187 size_t misc = 4; /* logfile, pidfile, stdout... */
322 /** Read existing pid from pidfile.
337 log_err("Could not read pidfile %s: %s",
344 log_err("Could not read pidfile %s: %s",
352 /* Empty pidfile means no pidfile... */
367 * @param pidfile: file name of pid file.
371 writepid (const char* pidfile, pid_t pid)
378 if((fd = open(pidfile, O_WRONLY | O_CREAT | O_TRUNC
383 log_err("cannot open pidfile %s: %s",
384 pidfile, strerror(errno));
392 log_err("cannot write to pidfile %s: %s",
393 pidfile, strerror(errno));
397 log_err("cannot write any bytes to pidfile %s: "
398 "write returns 0 bytes written", pidfile);
409 * @param pidfile: the file name of the pid file.
410 * @param inchroot: if pidfile is inchroot and we can thus expect to
414 checkoldpid(char* pidfile, int inchroot)
417 if((old = readpid(pidfile)) != -1) {
564 /* true if pidfile is inside chrootdir, or nochroot */
567 strncmp(cfg->pidfile, cfg->chrootdir,
571 if(cfg->pidfile && cfg->pidfile[0] && need_pidfile) {
572 /* calculate position of pidfile */
573 if(cfg->pidfile[0] == '/')
574 daemon->pidfile = strdup(cfg->pidfile);
575 else daemon->pidfile = fname_after_chroot(cfg->pidfile,
577 if(!daemon->pidfile)
578 fatal_exit("pidfile alloc: out of memory");
581 * drop makes a pidfile not removed when the server stopped
582 * last time. The server does not chown the pidfile for it,
584 * pidfile writable by unprivileged users, but used by
587 checkoldpid(daemon->pidfile, pidinchroot);
596 /* write new pidfile (while still root, so can be outside chroot) */
598 if(cfg->pidfile && cfg->pidfile[0] && need_pidfile) {
599 writepid(daemon->pidfile, getpid());
642 /* adjust stored pidfile for chroot */
643 if(daemon->pidfile && daemon->pidfile[0] &&
644 strncmp(daemon->pidfile, cfg->chrootdir,
646 char* old = daemon->pidfile;
647 daemon->pidfile = strdup(old+strlen(cfg->chrootdir));
649 if(!daemon->pidfile)
650 log_err("out of memory in pidfile adjust");
675 /* drop permissions after chroot, getpwnam, pidfile, syslog done*/
724 * @param need_pidfile: if false, no pidfile is checked or created.
775 /* this unlink may not work if the pidfile is located outside
777 if(daemon->pidfile) {
779 /* truncate pidfile */
780 fd = open(daemon->pidfile, O_WRONLY | O_TRUNC
787 /* delete pidfile */
788 unlink(daemon->pidfile);