aboutsummaryrefslogtreecommitdiff
path: root/libexec/atrun
diff options
context:
space:
mode:
authorSimon J. Gerraty <sjg@FreeBSD.org>2012-11-04 02:52:03 +0000
committerSimon J. Gerraty <sjg@FreeBSD.org>2012-11-04 02:52:03 +0000
commit23090366f729c56cab62de74c7a51792357e98a9 (patch)
treec511c885796e28ec571b5267e8f11f3b103d35e9 /libexec/atrun
parent7750ad47a9a7dbc83f87158464170c8640723293 (diff)
parent22ff74b2f44234d31540b1f7fd6c91489c37cad3 (diff)
downloadsrc-23090366f729c56cab62de74c7a51792357e98a9.tar.gz
src-23090366f729c56cab62de74c7a51792357e98a9.zip
Sync from head
Notes
Notes: svn path=/projects/bmake/; revision=242545
Diffstat (limited to 'libexec/atrun')
-rw-r--r--libexec/atrun/atrun.c21
-rw-r--r--libexec/atrun/atrun.man4
2 files changed, 22 insertions, 3 deletions
diff --git a/libexec/atrun/atrun.c b/libexec/atrun/atrun.c
index e4fc625fe3ee..8b0315e94451 100644
--- a/libexec/atrun/atrun.c
+++ b/libexec/atrun/atrun.c
@@ -33,6 +33,9 @@ static const char rcsid[] =
#include <sys/fcntl.h>
#include <sys/types.h>
#include <sys/stat.h>
+#ifdef __FreeBSD__
+#include <sys/sysctl.h>
+#endif
#include <sys/wait.h>
#include <sys/param.h>
#include <ctype.h>
@@ -123,7 +126,7 @@ run_file(const char *filename, uid_t uid, gid_t gid)
pid_t pid;
int fd_out, fd_in;
int queue;
- char mailbuf[MAXLOGNAME], fmt[49];
+ char mailbuf[MAXLOGNAME], fmt[64];
char *mailname = NULL;
FILE *stream;
int send_mail = 0;
@@ -454,7 +457,12 @@ main(int argc, char *argv[])
gid_t batch_gid;
int c;
int run_batch;
+#ifdef __FreeBSD__
+ size_t ncpu, ncpusz;
+ double load_avg = -1;
+#else
double load_avg = LOADAVG_MX;
+#endif
/* We don't need root privileges all the time; running under uid and gid daemon
* is fine.
@@ -472,8 +480,10 @@ main(int argc, char *argv[])
case 'l':
if (sscanf(optarg, "%lf", &load_avg) != 1)
perr("garbled option -l");
+#ifndef __FreeBSD__
if (load_avg <= 0.)
load_avg = LOADAVG_MX;
+#endif
break;
case 'd':
@@ -489,6 +499,15 @@ main(int argc, char *argv[])
if (chdir(ATJOB_DIR) != 0)
perr("cannot change to %s", ATJOB_DIR);
+#ifdef __FreeBSD__
+ if (load_avg <= 0.) {
+ ncpusz = sizeof(size_t);
+ if (sysctlbyname("hw.ncpu", &ncpu, &ncpusz, NULL, 0) < 0)
+ ncpu = 1;
+ load_avg = LOADAVG_MX * ncpu;
+ }
+#endif
+
/* Main loop. Open spool directory for reading and look over all the
* files in there. If the filename indicates that the job should be run
* and the x bit is set, fork off a child which sets its user and group
diff --git a/libexec/atrun/atrun.man b/libexec/atrun/atrun.man
index ec373b3420bc..cea322f6d1e2 100644
--- a/libexec/atrun/atrun.man
+++ b/libexec/atrun/atrun.man
@@ -1,5 +1,5 @@
.\" $FreeBSD$
-.Dd June 17, 2007
+.Dd October 30, 2012
.Dt ATRUN 8
.Os
.Sh NAME
@@ -45,7 +45,7 @@ e.g., locked out or expired.
.Bl -tag -width indent
.It Fl l Ar load_avg
Specify a limiting load factor, over which batch jobs should
-not be run, instead of the compiled in default of 1.5.
+not be run, instead of the default of 1.5 * number of active CPUs.
.It Fl d
Debug; print error messages to standard error instead of using
.Xr syslog 3 .