Page MenuHomeFreeBSD

D2616.id6554.diff
No OneTemporary

D2616.id6554.diff

Index: usr.bin/xargs/xargs.1
===================================================================
--- usr.bin/xargs/xargs.1
+++ usr.bin/xargs/xargs.1
@@ -33,7 +33,7 @@
.\" $FreeBSD$
.\" $xMach: xargs.1,v 1.2 2002/02/23 05:23:37 tim Exp $
.\"
-.Dd March 16, 2012
+.Dd May 21, 2015
.Dt XARGS 1
.Os
.Sh NAME
@@ -207,6 +207,11 @@
invocations of
.Ar utility
at once.
+If
+.Ar maxprocs
+is set to 0,
+.Nm
+will run as many processes as possible.
.It Fl p
Echo each command to be executed and ask the user whether it should be
executed.
Index: usr.bin/xargs/xargs.c
===================================================================
--- usr.bin/xargs/xargs.c
+++ usr.bin/xargs/xargs.c
@@ -46,8 +46,10 @@
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
-#include <sys/param.h>
#include <sys/wait.h>
+#include <sys/types.h>
+#include <sys/time.h>
+#include <sys/resource.h>
#include <err.h>
#include <errno.h>
@@ -100,6 +102,7 @@
long arg_max;
int ch, Jflag, nargs, nflag, nline;
size_t linelen;
+ struct rlimit reslimit;
char *endptr;
inpline = replstr = NULL;
@@ -159,8 +162,15 @@
oflag = 1;
break;
case 'P':
- if ((maxprocs = atoi(optarg)) <= 0)
- errx(1, "max. processes must be >0");
+ maxprocs = strtol(optarg, &endptr, 10);
+ if (getrlimit(RLIMIT_NPROC, &reslimit) != 0)
+ errx(1, "getrlimit failed");
+ if (*endptr != '\0')
+ errx(1, "invalid number for -P option");
+ if (maxprocs < 0)
+ errx(1, "value for -P option should be >= 0");
+ if (maxprocs == 0 || maxprocs > reslimit.rlim_cur)
+ maxprocs = reslimit.rlim_cur;
break;
case 'p':
pflag = 1;

File Metadata

Mime Type
text/plain
Expires
Sat, Nov 15, 3:39 PM (10 h, 56 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
25331164
Default Alt Text
D2616.id6554.diff (1 KB)

Event Timeline