Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change the signal when reload from a hub to a urg #146

Merged
merged 1 commit into from
Mar 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion contrib/cronie.systemd
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ After=auditd.service nss-user-lookup.target systemd-user-sessions.service time-s
[Service]
EnvironmentFile=/etc/sysconfig/crond
ExecStart=/usr/sbin/crond -n $CRONDARGS
ExecReload=/bin/kill -HUP $MAINPID
ExecReload=/bin/kill -URG $MAINPID
KillMode=process
Restart=on-failure
RestartSec=30s
Expand Down
12 changes: 10 additions & 2 deletions src/cron.c
Original file line number Diff line number Diff line change
Expand Up @@ -66,10 +66,11 @@ set_time(int),
cron_sleep(int, cron_db *),
sigchld_handler(int),
sighup_handler(int ATTRIBUTE_UNUSED),
sigurg_handler(int ATTRIBUTE_UNUSED),
sigchld_reaper(void),
sigintterm_handler(int ATTRIBUTE_UNUSED), parse_args(int c, char *v[]);

static volatile sig_atomic_t got_sighup, got_sigchld, got_sigintterm;
static volatile sig_atomic_t got_sighup, got_sigchld, got_sigintterm, got_sigurg;
static int timeRunning, virtualTime, clockTime;
static long GMToff;
static int DisableInotify;
Expand Down Expand Up @@ -151,8 +152,9 @@ void set_cron_watched(int fd) {
#endif

static void handle_signals(cron_db * database) {
if (got_sighup) {
if (got_sighup || got_sigurg) {
got_sighup = 0;
got_sigurg = 0;
#if defined WITH_INOTIFY
/* watches must be reinstated on reload */
if (inotify_enabled && (EnableClustering != 1)) {
Expand Down Expand Up @@ -243,6 +245,8 @@ int main(int argc, char *argv[]) {
sact.sa_handler = sigintterm_handler;
(void) sigaction(SIGINT, &sact, NULL);
(void) sigaction(SIGTERM, &sact, NULL);
sact.sa_handler = sigurg_handler;
(void) sigaction(SIGURG, &sact, NULL);

acquire_daemonlock(0);
set_cron_uid();
Expand Down Expand Up @@ -664,6 +668,10 @@ static void sigintterm_handler(int x ATTRIBUTE_UNUSED) {
got_sigintterm = 1;
}

static void sigurg_handler(int x ATTRIBUTE_UNUSED) {
got_sigurg = 1;
}

static void sigchld_reaper(void) {
WAIT_T waiter;
PID_T pid;
Expand Down