diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-02-17 18:40:12 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-02-17 18:40:12 +0000 |
commit | 16928aa0b6ec9a54be1fd7bbf6a14f532146c8e6 (patch) | |
tree | 059cc3f694e01a9773034e94b157c75d1ef632d9 /usr.sbin/cron | |
parent | 480fccaf5f966d585bf131b039db7e5babe68706 (diff) |
Add a -n flag and version string; from vixie
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r-- | usr.sbin/cron/cron.8 | 10 | ||||
-rw-r--r-- | usr.sbin/cron/cron.c | 16 | ||||
-rw-r--r-- | usr.sbin/cron/cron.h | 3 | ||||
-rw-r--r-- | usr.sbin/cron/crontab.c | 11 | ||||
-rw-r--r-- | usr.sbin/cron/globals.h | 3 |
5 files changed, 29 insertions, 14 deletions
diff --git a/usr.sbin/cron/cron.8 b/usr.sbin/cron/cron.8 index 2c4522cb24e..92cfe1fe207 100644 --- a/usr.sbin/cron/cron.8 +++ b/usr.sbin/cron/cron.8 @@ -24,7 +24,7 @@ .\" OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF .\" ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. .\" -.\" $OpenBSD: cron.8,v 1.17 2003/02/01 16:29:52 jmc Exp $ +.\" $OpenBSD: cron.8,v 1.18 2003/02/17 18:40:11 millert Exp $ .\" .Dd July 6, 2002 .Dt CRON 8 @@ -35,6 +35,7 @@ .Sh SYNOPSIS .Nm cron .Op Fl l Ar load_avg +.Op Fl n .Op Fl x Ar [ext,sch,proc,pars,load,misc,test,bit] .Sh DESCRIPTION The @@ -125,6 +126,13 @@ The default value is 1.5. To allow .Xr batch 1 jobs to run regardless of the load, a value of 0.0 may be used. +.It Fl n +By default, +.Nm +will detach from the current tty and become a daemon. +The +.Fl n +option disables this behavior and causes it to run in the foreground. .It Fl x Ar debug_flags If .Nm diff --git a/usr.sbin/cron/cron.c b/usr.sbin/cron/cron.c index 32f5e1172a5..69a096684cd 100644 --- a/usr.sbin/cron/cron.c +++ b/usr.sbin/cron/cron.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cron.c,v 1.28 2002/08/08 18:13:35 millert Exp $ */ +/* $OpenBSD: cron.c,v 1.29 2003/02/17 18:40:11 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved */ @@ -21,7 +21,7 @@ */ #if !defined(lint) && !defined(LINT) -static const char rcsid[] = "$OpenBSD: cron.c,v 1.28 2002/08/08 18:13:35 millert Exp $"; +static const char rcsid[] = "$OpenBSD: cron.c,v 1.29 2003/02/17 18:40:11 millert Exp $"; #endif #define MAIN_PROGRAM @@ -54,7 +54,7 @@ static void usage(void) { const char **dflags; - fprintf(stderr, "usage: %s [-l load_avg] [-x [", ProgramName); + fprintf(stderr, "usage: %s [-l load_avg] [-n] [-x [", ProgramName); for (dflags = DebugFlagNames; *dflags; dflags++) fprintf(stderr, "%s%s", *dflags, dflags[1] ? "," : "]"); fprintf(stderr, "]\n"); @@ -75,6 +75,7 @@ main(int argc, char *argv[]) { setlinebuf(stderr); #endif + NoFork = 0; parse_args(argc, argv); bzero((char *)&sact, sizeof sact); @@ -109,7 +110,7 @@ main(int argc, char *argv[]) { #if DEBUGGING (void) fprintf(stderr, "[%ld] cron started\n", (long)getpid()); #endif - } else { + } else if (NoFork == 0) { switch (fork()) { case -1: log_it("CRON",getpid(),"DEATH","can't fork"); @@ -117,7 +118,7 @@ main(int argc, char *argv[]) { break; case 0: /* child process */ - log_it("CRON",getpid(),"STARTUP","fork ok"); + log_it("CRON",getpid(),"STARTUP","CRON_VERSION"); (void) setsid(); if ((fd = open(_PATH_DEVNULL, O_RDWR, 0)) >= 0) { (void) dup2(fd, STDIN); @@ -496,7 +497,7 @@ parse_args(int argc, char *argv[]) { int argch; char *ep; - while (-1 != (argch = getopt(argc, argv, "l:x:"))) { + while (-1 != (argch = getopt(argc, argv, "l:nx:"))) { switch (argch) { case 'l': errno = 0; @@ -508,6 +509,9 @@ parse_args(int argc, char *argv[]) { usage(); } break; + case 'n': + NoFork = 1; + break; case 'x': if (!set_debug_flags(optarg)) usage(); diff --git a/usr.sbin/cron/cron.h b/usr.sbin/cron/cron.h index 987b6c993a5..9ea292831a0 100644 --- a/usr.sbin/cron/cron.h +++ b/usr.sbin/cron/cron.h @@ -1,4 +1,4 @@ -/* $OpenBSD: cron.h,v 1.7 2002/07/08 23:42:17 millert Exp $ */ +/* $OpenBSD: cron.h,v 1.8 2003/02/17 18:40:11 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -28,6 +28,7 @@ * vix 30dec86 [written] */ +#define CRON_VERSION "V5.0" #include "config.h" #include "externs.h" #include "pathnames.h" diff --git a/usr.sbin/cron/crontab.c b/usr.sbin/cron/crontab.c index 6d364f95208..9a03c47961a 100644 --- a/usr.sbin/cron/crontab.c +++ b/usr.sbin/cron/crontab.c @@ -1,4 +1,4 @@ -/* $OpenBSD: crontab.c,v 1.36 2002/08/10 20:28:51 millert Exp $ */ +/* $OpenBSD: crontab.c,v 1.37 2003/02/17 18:40:11 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved */ @@ -21,7 +21,7 @@ */ #if !defined(lint) && !defined(LINT) -static char const rcsid[] = "$OpenBSD: crontab.c,v 1.36 2002/08/10 20:28:51 millert Exp $"; +static char const rcsid[] = "$OpenBSD: crontab.c,v 1.37 2003/02/17 18:40:11 millert Exp $"; #endif /* crontab - install and manage per-user crontab files @@ -112,9 +112,10 @@ main(int argc, char *argv[]) { exitstatus = ERROR_EXIT; break; default: - exit(1); + exitstatus = ERROR_EXIT; + break; } - exit(0); + exit(exitstatus); /*NOTREACHED*/ } @@ -536,7 +537,7 @@ replace_cmd(void) { */ fprintf(tmp, "# DO NOT EDIT THIS FILE - edit the master and reinstall.\n"); fprintf(tmp, "# (%s installed on %-24.24s)\n", Filename, ctime(&now)); - fprintf(tmp, "# (Cron version -- %s)\n", rcsid); + fprintf(tmp, "# (Cron version %s -- %s)\n", CRON_VERSION, rcsid); /* copy the crontab to the tmp */ diff --git a/usr.sbin/cron/globals.h b/usr.sbin/cron/globals.h index 53ae2d79d78..edd3d4a82d7 100644 --- a/usr.sbin/cron/globals.h +++ b/usr.sbin/cron/globals.h @@ -1,4 +1,4 @@ -/* $OpenBSD: globals.h,v 1.4 2002/07/15 19:13:29 millert Exp $ */ +/* $OpenBSD: globals.h,v 1.5 2003/02/17 18:40:11 millert Exp $ */ /* * Copyright (c) 1997,2000 by Internet Software Consortium, Inc. @@ -58,6 +58,7 @@ XTRN const char *DowNames[] XTRN char *ProgramName INIT("amnesia"); XTRN int LineNumber INIT(0); XTRN time_t StartTime INIT(0); +XTRN int NoFork INIT(0); #if DEBUGGING XTRN int DebugFlags INIT(0); |