Module Name: src
Committed By: kre
Date: Tue Jan 30 19:05:07 UTC 2024
Modified Files:
src/bin/sh: jobs.c
Log Message:
PR bin/57894
For jobs -p for a non-job-control job, avoid just printing 0 (as
there is no process group pid) and instead output what we used to,
the pid of one of the processes in the job (usually the right one!)
XXX pullup -10 (9 and earlier not affected).
To generate a diff of this commit:
cvs rdiff -u -r1.118 -r1.119 src/bin/sh/jobs.c
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.118 src/bin/sh/jobs.c:1.119
--- src/bin/sh/jobs.c:1.118 Fri Apr 7 10:34:13 2023
+++ src/bin/sh/jobs.c Tue Jan 30 19:05:07 2024
@@ -1,4 +1,4 @@
-/* $NetBSD: jobs.c,v 1.118 2023/04/07 10:34:13 kre Exp $ */
+/* $NetBSD: jobs.c,v 1.119 2024/01/30 19:05:07 kre 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.118 2023/04/07 10:34:13 kre Exp $");
+__RCSID("$NetBSD: jobs.c,v 1.119 2024/01/30 19:05:07 kre Exp $");
#endif
#endif /* not lint */
@@ -439,7 +439,8 @@ showjob(struct output *out, struct job *
#if JOBS
if (mode & SHOW_PGID) {
/* output only the process group ID (lead process ID) */
- outfmt(out, "%ld\n", (long)jp->pgrp);
+ outfmt(out, "%ld\n",
+ jp->pgrp != 0 ? (long)jp->pgrp : (long)jp->ps->pid);
return;
}
#endif