[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Job-control not fully working in subshells since v4.4 ?
From: |
Luca Landi |
Subject: |
Job-control not fully working in subshells since v4.4 ? |
Date: |
Fri, 12 Jul 2019 21:06:40 +0200 |
Configuration Information [Automatically generated, do not change]:
Machine: x86_64
OS: linux-gnu
Compiler: gcc
Compilation CFLAGS: -g -O2 -Wno-parentheses -Wno-format-security
uname output: Linux ubuntu-14-04-4 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed
Jun 29 20:22:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
Machine Type: x86_64-pc-linux-gnu
Bash Version: 5.0
Patch Level: 7
Release Status: release
Description:
It appears that, since ca. v4.4, job-control from within an interactive subshell
is still allowed but does not work fully because the shell won't hand over
foreground-ness.
Please consider the following demonstrative session run on a vanilla 5.0.7.
The first execution is from a non-interactive shell which will hand over
foreground-ness to the subshell and below, while the second execution is
from an interactive shell which will not do it:
$ ./bash --norc --noprofile -c 'uname -a; echo $BASH_VERSION; (set -bm; echo
$-; sleep 3 & ps -s '$$' -o pid,ppid,pgid,tpgid,sid,s,cmd; wait); echo end'
Linux ubuntu-14-04-4 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29
20:22:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
5.0.7(1)-release
bhmBc
PID PPID PGID TPGID SID S CMD
1339 1270 1339 30211 1339 S -bash
30207 1339 30207 30211 1339 S ./bash --norc --noprofile -c uname -a;
echo $BASH_VERSION; (set -bm; echo $-
30209 30207 30207 30211 1339 S ./bash --norc --noprofile -c uname -a;
echo $BASH_VERSION; (set -bm; echo $-
30210 30209 30210 30211 1339 S sleep 3
30211 30209 30211 30211 1339 R ps -s 1339 -o pid,ppid,pgid,tpgid,sid,s,cmd
[1]+ Done sleep 3
end
$
$ ./bash --norc --noprofile
bash-5.0$
bash-5.0$ uname -a; echo $BASH_VERSION; (set -bm; echo $-; sleep 3 & ps -s 1339
-o pid,ppid,pgid,tpgid,sid,s,cmd; wait); echo end
Linux ubuntu-14-04-4 4.2.0-42-generic #49~14.04.1-Ubuntu SMP Wed Jun 29
20:22:11 UTC 2016 x86_64 x86_64 x86_64 GNU/Linux
5.0.7(1)-release
bhimBHs
PID PPID PGID TPGID SID S CMD
1339 1270 1339 30214 1339 S -bash
30212 1339 30212 30214 1339 S ./bash --norc --noprofile
30214 30212 30214 30214 1339 S ./bash --norc --noprofile
30215 30214 30215 30214 1339 S sleep 3
30216 30214 30216 30214 1339 R ps -s 1339 -o pid,ppid,pgid,tpgid,sid,s,cmd
end
bash-5.0$
$
I get same result on v4.4.20(1) stock on Ubuntu 18.04 as well as on 5.0.3(1)
on Ubuntu 19.04.
On Bash 4.3 stock on Ubuntu 16.04 (and 14.04 also tested) instead, everything
seems all right:
$ bash -c 'uname -a; echo $BASH_VERSION; (set -bm; echo $-; sleep 3 & ps -s
'$$' -o pid,ppid,pgid,tpgid,sid,s,cmd; wait); echo end'
Linux ubuntu-16-04 4.4.0-154-generic #181-Ubuntu SMP Tue Jun 25 05:29:03 UTC
2019 x86_64 x86_64 x86_64 GNU/Linux
4.3.48(1)-release
bhmBc
PID PPID PGID TPGID SID S CMD
1885 1879 1885 2667 1885 S bash
2663 1885 2663 2667 1885 S bash -c uname -a; echo $BASH_VERSION; (set
-bm; echo $-; sleep 3 & ps -s 1885 -o pid,ppid,pgid,tpgid,sid,s,cmd;
2665 2663 2663 2667 1885 S bash -c uname -a; echo $BASH_VERSION; (set
-bm; echo $-; sleep 3 & ps -s 1885 -o pid,ppid,pgid,tpgid,sid,s,cmd;
2666 2665 2666 2667 1885 S sleep 3
2667 2665 2667 2667 1885 R ps -s 1885 -o pid,ppid,pgid,tpgid,sid,s,cmd
[1]+ Completato sleep 3
end
$
$ uname -a; echo $BASH_VERSION; (set -bm; echo $-; sleep 3 & ps -s $$ -o
pid,ppid,pgid,tpgid,sid,s,cmd; wait); echo end
Linux ubuntu-16-04 4.4.0-154-generic #181-Ubuntu SMP Tue Jun 25 05:29:03 UTC
2019 x86_64 x86_64 x86_64 GNU/Linux
4.3.48(1)-release
bhimBH
PID PPID PGID TPGID SID S CMD
1885 1879 1885 2698 1885 S bash
2696 1885 2696 2698 1885 S bash
2697 2696 2697 2698 1885 S sleep 3
2698 2696 2698 2698 1885 R ps -s 1885 -o pid,ppid,pgid,tpgid,sid,s,cmd
end
$
I suppose v4.3's behavior is the correct one ?
Repeat-By:
Sample sequence of commands as in below (mind the $$ of course):
echo start; (set -bm; echo $-; sleep 3 & ps -s $$ -o
pid,ppid,pgid,tpgid,sid,s,cmd; wait); echo end
- Job-control not fully working in subshells since v4.4 ?,
Luca Landi <=