Module Name:    src
Committed By:   christos
Date:           Sat Sep 11 20:43:32 UTC 2021

Modified Files:
        src/bin/sh: jobs.c jobs.h sh.1

Log Message:
Add jobs -Z (like in zsh(1)) to setproctitle(3).


To generate a diff of this commit:
cvs rdiff -u -r1.110 -r1.111 src/bin/sh/jobs.c
cvs rdiff -u -r1.24 -r1.25 src/bin/sh/jobs.h
cvs rdiff -u -r1.229 -r1.230 src/bin/sh/sh.1

Please note that diffs are not public domain; they are subject to the
copyright notices on the relevant files.

Modified files:

Index: src/bin/sh/jobs.c
diff -u src/bin/sh/jobs.c:1.110 src/bin/sh/jobs.c:1.111
--- src/bin/sh/jobs.c:1.110	Sun Apr  4 09:24:07 2021
+++ src/bin/sh/jobs.c	Sat Sep 11 16:43:32 2021
@@ -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 @@ jobscmd(int argc, char **argv)
 	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;

Index: src/bin/sh/jobs.h
diff -u src/bin/sh/jobs.h:1.24 src/bin/sh/jobs.h:1.25
--- src/bin/sh/jobs.h:1.24	Sun Apr  4 09:24:07 2021
+++ src/bin/sh/jobs.h	Sat Sep 11 16:43:32 2021
@@ -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 */
 
 
 /*

Index: src/bin/sh/sh.1
diff -u src/bin/sh/sh.1:1.229 src/bin/sh/sh.1:1.230
--- src/bin/sh/sh.1:1.229	Fri Sep 18 03:21:26 2020
+++ src/bin/sh/sh.1	Sat Sep 11 16:43:32 2021
@@ -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 @@ or with
 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 @@ With the
 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.

Reply via email to