/* True only if we created pidfile which is *file*, not /dev/null etc */
extern smallint wrote_pidfile;
void write_pidfile(const char *path) FAST_FUNC;
+void write_pidfile_std_path_and_ext(const char *path) FAST_FUNC;
+void remove_pidfile_std_path_and_ext(const char *path) FAST_FUNC;
#define remove_pidfile(path) do { if (wrote_pidfile) unlink(path); } while (0)
#else
enum { wrote_pidfile = 0 };
+#define write_pidfile_std_path_and_ext(path) ((void)0)
+#define remove_pidfile_std_path_and_ext(path) ((void)0)
#define write_pidfile(path) ((void)0)
#define remove_pidfile(path) ((void)0)
#endif
}
close(pid_fd);
}
+
+void FAST_FUNC write_pidfile_std_path_and_ext(const char *name)
+{
+ char buf[sizeof(CONFIG_PID_FILE_PATH) + 64];
+
+ snprintf(buf, sizeof(buf), CONFIG_PID_FILE_PATH"/%s.pid", name);
+ write_pidfile(buf);
+}
+
+void FAST_FUNC remove_pidfile_std_path_and_ext(const char *name)
+{
+ char buf[sizeof(CONFIG_PID_FILE_PATH) + 64];
+
+ if (!wrote_pidfile)
+ return;
+ snprintf(buf, sizeof(buf), CONFIG_PID_FILE_PATH"/%s.pid", name);
+ unlink(buf);
+}
log8("crond (busybox "BB_VER") started, log level %d", G.log_level);
rescan_crontab_dir();
- write_pidfile(CONFIG_PID_FILE_PATH "/crond.pid");
+ write_pidfile_std_path_and_ext("crond");
#if ENABLE_FEATURE_CROND_SPECIAL_TIMES
if (touch_reboot_file())
start_jobs(START_ME_REBOOT); /* start @reboot entries, if any */
static void shutdown_on_signal(int sig UNUSED_PARAM)
{
- remove_pidfile(CONFIG_PID_FILE_PATH "/watchdog.pid");
+ remove_pidfile_std_path_and_ext("watchdog");
shutdown_watchdog();
_exit(EXIT_SUCCESS);
}
stimer_duration, htimer_duration * 1000);
#endif
- write_pidfile(CONFIG_PID_FILE_PATH "/watchdog.pid");
+ write_pidfile_std_path_and_ext("watchdog");
while (1) {
/*
if (ENABLE_FEATURE_CLEAN_UP)
close(sep->se_fd);
}
- remove_pidfile(CONFIG_PID_FILE_PATH "/inetd.pid");
+ remove_pidfile_std_path_and_ext("inetd");
exit(EXIT_SUCCESS);
}
setgroups(1, &gid);
}
- write_pidfile(CONFIG_PID_FILE_PATH "/inetd.pid");
+ write_pidfile_std_path_and_ext("inetd");
/* never fails under Linux (except if you pass it bad arguments) */
getrlimit(RLIMIT_NOFILE, &rlim_ofile);
*/
cnt = G.peer_cnt * (INITIAL_SAMPLES + 1);
- write_pidfile(CONFIG_PID_FILE_PATH "/ntpd.pid");
+ write_pidfile_std_path_and_ext("ntpd");
while (!bb_got_signal) {
llist_t *item;
}
} /* while (!bb_got_signal) */
- remove_pidfile(CONFIG_PID_FILE_PATH "/ntpd.pid");
+ remove_pidfile_std_path_and_ext("ntpd");
kill_myself_with_sig(bb_got_signal);
}
syslog(LOG_NOTICE, "klogd started: %s", bb_banner);
- write_pidfile(CONFIG_PID_FILE_PATH "/klogd.pid");
+ write_pidfile_std_path_and_ext("klogd");
used = 0;
while (!bb_got_signal) {
klogd_close();
syslog(LOG_NOTICE, "klogd: exiting");
- remove_pidfile(CONFIG_PID_FILE_PATH "/klogd.pid");
+ remove_pidfile_std_path_and_ext("klogd");
if (bb_got_signal)
kill_myself_with_sig(bb_got_signal);
return EXIT_FAILURE;
} /* while (!bb_got_signal) */
timestamp_and_log_internal("syslogd exiting");
- remove_pidfile(CONFIG_PID_FILE_PATH "/syslogd.pid");
+ remove_pidfile_std_path_and_ext("syslogd");
ipcsyslog_cleanup();
if (option_mask32 & OPT_kmsg)
kmsg_cleanup();
}
//umask(0); - why??
- write_pidfile(CONFIG_PID_FILE_PATH "/syslogd.pid");
+ write_pidfile_std_path_and_ext("syslogd");
do_syslogd();
/* return EXIT_SUCCESS; */