diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-14 15:58:14 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 2003-04-14 15:58:14 +0000 |
commit | 42914e66d165e809734fc1be654b16e52c16a5e3 (patch) | |
tree | eab823ef46eb9a42270e43efac51aa13ad658e73 /usr.sbin/cron | |
parent | 8d0bc82baf50da74d92ad716322a47542ea66e40 (diff) |
Use setproctitle() instead of the CAPITALIZE_FOR_PS hack. Inspired
by similar changes in FreeBSD and NetBSD. For at jobs, include the
job number in the proctitle.
Diffstat (limited to 'usr.sbin/cron')
-rw-r--r-- | usr.sbin/cron/atrun.c | 22 | ||||
-rw-r--r-- | usr.sbin/cron/config.h | 7 | ||||
-rw-r--r-- | usr.sbin/cron/do_command.c | 17 |
3 files changed, 13 insertions, 33 deletions
diff --git a/usr.sbin/cron/atrun.c b/usr.sbin/cron/atrun.c index 9453e19a105..fe74534d70a 100644 --- a/usr.sbin/cron/atrun.c +++ b/usr.sbin/cron/atrun.c @@ -1,4 +1,4 @@ -/* $OpenBSD: atrun.c,v 1.7 2003/03/15 00:39:01 millert Exp $ */ +/* $OpenBSD: atrun.c,v 1.8 2003/04/14 15:58:13 millert Exp $ */ /* * Copyright (c) 2002-2003 Todd C. Miller <Todd.Miller@courtesan.com> @@ -17,7 +17,7 @@ */ #if !defined(lint) && !defined(LINT) -static const char rcsid[] = "$OpenBSD: atrun.c,v 1.7 2003/03/15 00:39:01 millert Exp $"; +static const char rcsid[] = "$OpenBSD: atrun.c,v 1.8 2003/04/14 15:58:13 millert Exp $"; #endif #include "cron.h" @@ -249,6 +249,10 @@ run_job(atjob *job, char *atfile) } unlink(atfile); + /* We don't want the atjobs dir in the log messages. */ + if ((cp = strrchr(atfile, '/')) != NULL) + atfile = cp + 1; + /* Fork so other pending jobs don't have to wait for us to finish. */ switch (fork()) { case 0: @@ -373,18 +377,8 @@ run_job(atjob *job, char *atfile) _exit(ERROR_EXIT); } -#ifdef CAPITALIZE_FOR_PS - /* mark ourselves as different to PS command watchers by upshifting - * our program name. This has no effect on some kernels. - * XXX - really want to set proc title to at job name instead - */ - /*local*/{ - char *pch; - - for (pch = ProgramName; *pch; pch++) - *pch = MkUpper(*pch); - } -#endif /* CAPITALIZE_FOR_PS */ + /* mark ourselves as different to PS command watchers */ + setproctitle("atrun %s", atfile); pipe(output_pipe); /* child's stdout/stderr */ diff --git a/usr.sbin/cron/config.h b/usr.sbin/cron/config.h index 74a30b3b62d..8aebb3a3c45 100644 --- a/usr.sbin/cron/config.h +++ b/usr.sbin/cron/config.h @@ -1,4 +1,4 @@ -/* $OpenBSD: config.h,v 1.15 2003/02/20 20:38:08 millert Exp $ */ +/* $OpenBSD: config.h,v 1.16 2003/04/14 15:58:13 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -80,11 +80,6 @@ */ #define SYSLOG /*-*/ - /* if you want cron to capitalize its name in ps - * when running a job. Does not work on SYSV. - */ -#define CAPITALIZE_FOR_PS /*-*/ - /* if you have a tm_gmtoff member in struct tm. * If not, we will have to compute the value ourselves. */ diff --git a/usr.sbin/cron/do_command.c b/usr.sbin/cron/do_command.c index 05363d67b95..1f489db62cd 100644 --- a/usr.sbin/cron/do_command.c +++ b/usr.sbin/cron/do_command.c @@ -1,4 +1,4 @@ -/* $OpenBSD: do_command.c,v 1.23 2003/02/20 20:38:08 millert Exp $ */ +/* $OpenBSD: do_command.c,v 1.24 2003/04/14 15:58:13 millert Exp $ */ /* Copyright 1988,1990,1993,1994 by Paul Vixie * All rights reserved @@ -22,7 +22,7 @@ */ #if !defined(lint) && !defined(LINT) -static char const rcsid[] = "$OpenBSD: do_command.c,v 1.23 2003/02/20 20:38:08 millert Exp $"; +static char const rcsid[] = "$OpenBSD: do_command.c,v 1.24 2003/04/14 15:58:13 millert Exp $"; #endif #include "cron.h" @@ -69,17 +69,8 @@ child_process(entry *e, user *u) { Debug(DPROC, ("[%ld] child_process('%s')\n", (long)getpid(), e->cmd)) -#ifdef CAPITALIZE_FOR_PS - /* mark ourselves as different to PS command watchers by upshifting - * our program name. This has no effect on some kernels. - */ - /*local*/{ - char *pch; - - for (pch = ProgramName; *pch; pch++) - *pch = MkUpper(*pch); - } -#endif /* CAPITALIZE_FOR_PS */ + /* mark ourselves as different to PS command watchers */ + setproctitle("running job"); /* discover some useful and important environment settings */ |