From d78bd61e556d8cd728414b553edf3ccd30580b4d Mon Sep 17 00:00:00 2001 From: Ron Yorston Date: Thu, 14 Oct 2021 13:28:46 +0100 Subject: ash: display job id and pid of background commands Several common shells display the job id and pid of background commands. Even the Unix V7 Bourne shell displays the pid. This is unrelated to whether job control is available or enabled. --- shell/ash.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/shell/ash.c b/shell/ash.c index f211df83a..3e741d7d2 100644 --- a/shell/ash.c +++ b/shell/ash.c @@ -4401,7 +4401,7 @@ set_curjob(struct job *jp, unsigned mode) } } -#if JOBS || JOBS_WIN32 || DEBUG +#if JOBS || ENABLE_PLATFORM_MINGW32 || DEBUG static int jobno(const struct job *jp) { @@ -5910,6 +5910,10 @@ forkparent(struct job *jp, union node *n, int mode, HANDLE proc) if (mode == FORK_BG) { backgndpid = pid; /* set $! */ set_curjob(jp, CUR_RUNNING); +#if ENABLE_PLATFORM_MINGW32 + if (iflag && jp && jp->nprocs == 0) + fprintf(stderr, "[%d] %"PID_FMT"d\n", jobno(jp), pid); +#endif } if (jp) { struct procstat *ps = &jp->ps[jp->nprocs++]; -- cgit v1.2.3-55-g6feb