Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/usr.bin/pwait add flag that let's you not wait for all the p...
details: https://anonhg.NetBSD.org/src/rev/8e27cab8571d
branches: trunk
changeset: 336516:8e27cab8571d
user: christos <christos%NetBSD.org@localhost>
date: Wed Mar 04 16:36:12 2015 +0000
description:
add flag that let's you not wait for all the processes specified.
diffstat:
usr.bin/pwait/pwait.1 | 9 ++++++---
usr.bin/pwait/pwait.c | 16 +++++++++++-----
2 files changed, 17 insertions(+), 8 deletions(-)
diffs (96 lines):
diff -r 4e94e08c7973 -r 8e27cab8571d usr.bin/pwait/pwait.1
--- a/usr.bin/pwait/pwait.1 Wed Mar 04 16:18:04 2015 +0000
+++ b/usr.bin/pwait/pwait.1 Wed Mar 04 16:36:12 2015 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: pwait.1,v 1.3 2015/03/03 19:59:48 christos Exp $
+.\" $NetBSD: pwait.1,v 1.4 2015/03/04 16:36:12 christos Exp $
.\"
.\" Copyright (c) 2004-2009, Jilles Tjoelker
.\" All rights reserved.
@@ -33,7 +33,7 @@
.\"
.\" $FreeBSD: head/bin/pwait/pwait.1 233648 2012-03-29 05:02:12Z eadler $
.\"
-.Dd March 3, 2015
+.Dd March 4, 2015
.Dt PWAIT 1
.Os
.Sh NAME
@@ -41,7 +41,7 @@
.Nd wait for processes to terminate
.Sh SYNOPSIS
.Nm
-.Op Fl sv
+.Op Fl isv
.Op Fl t Ar timeout
.Ar pid
\&...
@@ -52,6 +52,9 @@
.Pp
The following option is available:
.Bl -tag -width indent
+.It Fl i
+Don't wait for all the processes, exit after the first process or group
+of processes exit.
.It Fl s
Exit with the status code of the first non-zero exit status pid, or
if timed out exit with
diff -r 4e94e08c7973 -r 8e27cab8571d usr.bin/pwait/pwait.c
--- a/usr.bin/pwait/pwait.c Wed Mar 04 16:18:04 2015 +0000
+++ b/usr.bin/pwait/pwait.c Wed Mar 04 16:36:12 2015 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: pwait.c,v 1.4 2015/03/04 13:31:53 christos Exp $ */
+/* $NetBSD: pwait.c,v 1.5 2015/03/04 16:36:12 christos Exp $ */
/*-
* Copyright (c) 2004-2009, Jilles Tjoelker
@@ -37,7 +37,7 @@
#ifdef __FBSDID
__FBSDID("$FreeBSD: head/bin/pwait/pwait.c 245506 2013-01-16 18:15:25Z delphij $");
#endif
-__RCSID("$NetBSD: pwait.c,v 1.4 2015/03/04 13:31:53 christos Exp $");
+__RCSID("$NetBSD: pwait.c,v 1.5 2015/03/04 16:36:12 christos Exp $");
#include <sys/types.h>
#include <sys/event.h>
@@ -58,7 +58,7 @@
usage(void)
{
- fprintf(stderr, "Usage: %s [-sv] [-t <timeout>] <pid> ...\n",
+ fprintf(stderr, "Usage: %s [-isv] [-t <timeout>] <pid> ...\n",
getprogname());
exit(EX_USAGE);
}
@@ -72,7 +72,7 @@
int kq;
struct kevent *e;
int verbose = 0, childstatus = 0;
- int opt, duplicate, status;
+ int opt, duplicate, status, immediately = 0;
size_t nleft, n, i;
pid_t pid;
char *s, *end;
@@ -80,8 +80,11 @@
struct timespec ts, *tsp;
setprogname(argv[0]);
- while ((opt = getopt(argc, argv, "st:v")) != -1) {
+ while ((opt = getopt(argc, argv, "ist:v")) != -1) {
switch (opt) {
+ case 'i':
+ immediately = 1;
+ break;
case 's':
childstatus = 1;
break;
@@ -187,6 +190,9 @@
return status;
}
nleft -= n;
+ // n != 0 here, belt-n-suspenders...
+ if (immediately && n)
+ break;
}
return EX_OK;
Home |
Main Index |
Thread Index |
Old Index