Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/bin/sh Add jobs -Z (like in zsh(1)) to setproctitle(3).
details: https://anonhg.NetBSD.org/src/rev/4c2e53da23fd
branches: trunk
changeset: 1023512:4c2e53da23fd
user: christos <christos%NetBSD.org@localhost>
date: Sat Sep 11 20:43:32 2021 +0000
description:
Add jobs -Z (like in zsh(1)) to setproctitle(3).
diffstat:
bin/sh/jobs.c | 22 +++++++++++++++++-----
bin/sh/jobs.h | 3 ++-
bin/sh/sh.1 | 11 ++++++++---
3 files changed, 27 insertions(+), 9 deletions(-)
diffs (101 lines):
diff -r e6371407b87a -r 4c2e53da23fd bin/sh/jobs.c
--- a/bin/sh/jobs.c Sat Sep 11 20:28:03 2021 +0000
+++ b/bin/sh/jobs.c Sat Sep 11 20:43:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: jobs.c,v 1.110 2021/04/04 13:24:07 kre Exp $ */
+/* $NetBSD: jobs.c,v 1.111 2021/09/11 20:43:32 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -37,7 +37,7 @@
#if 0
static char sccsid[] = "@(#)jobs.c 8.5 (Berkeley) 5/4/95";
#else
-__RCSID("$NetBSD: jobs.c,v 1.110 2021/04/04 13:24:07 kre Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.111 2021/09/11 20:43:32 christos Exp $");
#endif
#endif /* not lint */
@@ -550,11 +550,23 @@
int mode, m;
mode = 0;
- while ((m = nextopt("lp")))
- if (m == 'l')
+ while ((m = nextopt("lpZ")))
+ switch (m) {
+ case 'l':
mode = SHOW_PID;
- else
+ break;
+ case 'p':
mode = SHOW_PGID;
+ break;
+ case 'Z':
+ mode = SHOW_PROCTITLE;
+ break;
+ }
+
+ if (mode == SHOW_PROCTITLE) {
+ setproctitle("%s", *argptr);
+ return 0;
+ }
if (!iflag && !posix)
mode |= SHOW_NO_FREE;
diff -r e6371407b87a -r 4c2e53da23fd bin/sh/jobs.h
--- a/bin/sh/jobs.h Sat Sep 11 20:28:03 2021 +0000
+++ b/bin/sh/jobs.h Sat Sep 11 20:43:32 2021 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: jobs.h,v 1.24 2021/04/04 13:24:07 kre Exp $ */
+/* $NetBSD: jobs.h,v 1.25 2021/09/11 20:43:32 christos Exp $ */
/*-
* Copyright (c) 1991, 1993
@@ -49,6 +49,7 @@
#define SHOW_SIGNALLED 0x10 /* only if stopped/exited on signal */
#define SHOW_ISSIG 0x20 /* job was signalled */
#define SHOW_NO_FREE 0x40 /* do not free job */
+#define SHOW_PROCTITLE 0x80 /* set the process title */
/*
diff -r e6371407b87a -r 4c2e53da23fd bin/sh/sh.1
--- a/bin/sh/sh.1 Sat Sep 11 20:28:03 2021 +0000
+++ b/bin/sh/sh.1 Sat Sep 11 20:43:32 2021 +0000
@@ -1,4 +1,4 @@
-.\" $NetBSD: sh.1,v 1.229 2020/09/18 07:21:26 wiz Exp $
+.\" $NetBSD: sh.1,v 1.230 2021/09/11 20:43:32 christos Exp $
.\" Copyright (c) 1991, 1993
.\" The Regents of the University of California. All rights reserved.
.\"
@@ -31,7 +31,7 @@
.\"
.\" @(#)sh.1 8.6 (Berkeley) 5/4/95
.\"
-.Dd September 18, 2020
+.Dd September 11, 2021
.Dt SH 1
.\" everything except c o and s (keep them ordered)
.ds flags abCEeFfhIiLmnpquVvXx
@@ -2977,7 +2977,7 @@
there is no process group leader (should not happen),
and otherwise exits with status 0.
.\"
-.It Ic jobs Oo Fl l Ns \&| Ns Fl p Oc Op Ar job ...
+.It Ic jobs Oo Fl l Ns \&| Ns Fl p \&| Fl Z Oc Op Ar job ...
Without
.Ar job
arguments,
@@ -3005,6 +3005,11 @@
flag, the output contains only the process identifier of the lead
process.
.Pp
+With the
+.Fl Z
+flag, the process command line is set using
+.Xr setproctitle 3 .
+.Pp
In an interactive shell, each job shown as completed in the output
from the jobs command is implicitly waited for, and is removed from
the jobs table, never to be seen again.
Home |
Main Index |
Thread Index |
Old Index