From 00f175801bafd427df9ed9f53cf32c11a8503112 Mon Sep 17 00:00:00 2001 From: w30023233 Date: Tue, 22 Mar 2022 19:56:36 +0800 Subject: [PATCH] Add switch -f for foreground mode --- man/cron.8 | 3 +++ src/cron.c | 4 +++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/man/cron.8 b/man/cron.8 index 435f7cc..e756477 100644 --- a/man/cron.8 +++ b/man/cron.8 @@ -169,6 +169,9 @@ must not enable .I pam_loginuid.so module. .TP +.B "\-f" +the same as -n, consistent with other crond implementations. +.TP .B "\-p" Allows .I Cron diff --git a/src/cron.c b/src/cron.c index da9aee3..4297fc4 100644 --- a/src/cron.c +++ b/src/cron.c @@ -182,6 +182,7 @@ static void usage(void) { fprintf(stderr, " -i deamon runs without inotify support\n"); fprintf(stderr, " -m off, or specify preferred client for sending mails\n"); fprintf(stderr, " -n run in foreground\n"); + fprintf(stderr, " -f run in foreground, the same as -n\n"); fprintf(stderr, " -p permit any crontab\n"); fprintf(stderr, " -P inherit PATH from environment instead of using default value"); fprintf(stderr, " of \"%s\"\n", _PATH_DEFPATH); @@ -690,13 +691,14 @@ static void sigchld_reaper(void) { static void parse_args(int argc, char *argv[]) { int argch; - while (-1 != (argch = getopt(argc, argv, "hnpsiPx:m:cV"))) { + while (-1 != (argch = getopt(argc, argv, "hnfpsiPx:m:cV"))) { switch (argch) { case 'x': if (!set_debug_flags(optarg)) usage(); break; case 'n': + case 'f': NoFork = 1; break; case 'p':