From owner-svn-src-all@freebsd.org Wed Jul 19 19:41:14 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 5633FD7CEC7; Wed, 19 Jul 2017 19:41:14 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 30DA6692C0; Wed, 19 Jul 2017 19:41:14 +0000 (UTC) (envelope-from ngie@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v6JJfDYS000995; Wed, 19 Jul 2017 19:41:13 GMT (envelope-from ngie@FreeBSD.org) Received: (from ngie@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v6JJfDX3000992; Wed, 19 Jul 2017 19:41:13 GMT (envelope-from ngie@FreeBSD.org) Message-Id: <201707191941.v6JJfDX3000992@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: ngie set sender to ngie@FreeBSD.org using -f From: Ngie Cooper Date: Wed, 19 Jul 2017 19:41:13 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r321237 - stable/10/usr.sbin/cron/cron X-SVN-Group: stable-10 X-SVN-Commit-Author: ngie X-SVN-Commit-Paths: stable/10/usr.sbin/cron/cron X-SVN-Commit-Revision: 321237 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Jul 2017 19:41:14 -0000 Author: ngie Date: Wed Jul 19 19:41:13 2017 New Revision: 321237 URL: https://svnweb.freebsd.org/changeset/base/321237 Log: MFC r304570,r321235: r304570 (by trasz): Add the "-n" flag to cron(8), to prevent it from daemonizing. This makes it possible to use it with external supervisors. The "-n" flag name is compatible with Linux, NetBSD, and OpenBSD. r321235: Fix trivial whitespace bug introduced in usage message changes for -n support (r304570). Modified: stable/10/usr.sbin/cron/cron/cron.8 stable/10/usr.sbin/cron/cron/cron.c Directory Properties: stable/10/ (props changed) Modified: stable/10/usr.sbin/cron/cron/cron.8 ============================================================================== --- stable/10/usr.sbin/cron/cron/cron.8 Wed Jul 19 19:39:26 2017 (r321236) +++ stable/10/usr.sbin/cron/cron/cron.8 Wed Jul 19 19:41:13 2017 (r321237) @@ -17,7 +17,7 @@ .\" .\" $FreeBSD$ .\" -.Dd June 29, 2008 +.Dd August 21, 2016 .Dt CRON 8 .Os .Sh NAME @@ -28,6 +28,7 @@ .Op Fl j Ar jitter .Op Fl J Ar rootjitter .Op Fl m Ar mailto +.Op Fl n .Op Fl s .Op Fl o .Op Fl x Ar debugflag Ns Op , Ns Ar ... @@ -132,6 +133,8 @@ set to a null string, usually specified in a shell as .Li '' or .Li \*q\*q . +.It Fl n +Don't daemonize, run in foreground instead. .It Fl s Enable special handling of situations when the GMT offset of the local timezone changes, such as the switches between the standard time and Modified: stable/10/usr.sbin/cron/cron/cron.c ============================================================================== --- stable/10/usr.sbin/cron/cron/cron.c Wed Jul 19 19:39:26 2017 (r321236) +++ stable/10/usr.sbin/cron/cron/cron.c Wed Jul 19 19:41:13 2017 (r321237) @@ -49,6 +49,7 @@ static int run_at_secres(cron_db *); static time_t last_time = 0; static int dst_enabled = 0; +static int dont_daemonize = 0; struct pidfh *pfh; static void @@ -58,7 +59,7 @@ usage() { #endif fprintf(stderr, "usage: cron [-j jitter] [-J rootjitter] " - "[-m mailto] [-s] [-o] [-x debugflag[,...]]\n"); + "[-m mailto] [-n] [-s] [-o] [-x debugflag[,...]]\n"); #if DEBUGGING fprintf(stderr, "\ndebugflags: "); @@ -136,7 +137,7 @@ main(argc, argv) if (0) { # endif (void) fprintf(stderr, "[%d] cron started\n", getpid()); - } else { + } else if (dont_daemonize == 0) { if (daemon(1, 0) == -1) { pidfile_remove(pfh); log_it("CRON",getpid(),"DEATH","can't become daemon"); @@ -512,7 +513,7 @@ parse_args(argc, argv) int argch; char *endp; - while ((argch = getopt(argc, argv, "j:J:m:osx:")) != -1) { + while ((argch = getopt(argc, argv, "j:J:m:nosx:")) != -1) { switch (argch) { case 'j': Jitter = strtoul(optarg, &endp, 10); @@ -528,6 +529,9 @@ parse_args(argc, argv) break; case 'm': defmailto = optarg; + break; + case 'n': + dont_daemonize = 1; break; case 'o': dst_enabled = 0;