Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > gnu.bash.bug > #14818
| Path | csiph.com!xmission!news.snarked.org!news.linkpendium.com!news.linkpendium.com!panix!usenet.stanford.edu!not-for-mail |
|---|---|
| From | Christopher Jefferson <caj21@st-andrews.ac.uk> |
| Newsgroups | gnu.bash.bug |
| Subject | Re: Strange behaviour from jobs -p in a subshell |
| Date | Wed, 14 Nov 2018 09:48:49 +0000 |
| Lines | 30 |
| Approved | bug-bash@gnu.org |
| Message-ID | <mailman.4028.1542188959.1284.bug-bash@gnu.org> (permalink) |
| References | <b17b162c-9f60-37fc-2473-30e267a681d2@st-andrews.ac.uk> <563c6188-c905-db81-f330-b79bf17e4413@case.edu> |
| NNTP-Posting-Host | lists.gnu.org |
| Mime-Version | 1.0 |
| Content-Type | text/plain; charset="utf-8" |
| Content-Transfer-Encoding | base64 |
| X-Trace | usenet.stanford.edu 1542188959 10629 208.118.235.17 (14 Nov 2018 09:49:19 GMT) |
| X-Complaints-To | action@cs.stanford.edu |
| To | "chet.ramey@case.edu" <chet.ramey@case.edu>, "bug-bash@gnu.org" <bug-bash@gnu.org> |
| Envelope-to | bug-bash@gnu.org |
| DKIM-Signature | v=1; a=rsa-sha256; c=simple/simple; d=st-andrews.ac.uk; s=mailhost; t=1542188934; bh=SkPBsmP4xzt0ReYM3BZ3D68Peu8KhYEoJD3xJHpF5SA=; h=From:To:Subject:Date:References:In-Reply-To:From; b=o4QtJrl6xIJcwejPDfA2cHnc9c1VrSVw8/ftdYzp2E0LY1TqakaY+0tqn/eRG6yOH 6QnpH3Bnrr4OGteW9g3brUJoB8tq09hQKk9uq6QMrHtzcPweUPxrGJBXCByu+QpZ7/ 7fUEu5tHysWLiCaLqHxf119IAKSY5Ak8N1pN9rULELqSQLKwm8tjNmfanytK/0Hijl GlpDwa7KtHdc3XnrdTyv7eVIPOw40x1d1rmNS8U+p0F22nL5bfScFVcewryN98p7ul DWXTaVrZOyTefGg9VLTTWA8fQ8WRjZySjg7bJuSvSDDEUb932tDgPVlOoTSlO4y05k 6HU0kwOROcedQ== |
| X-StAndrews-MailScanner-From | caj21@st-andrews.ac.uk |
| X-StAndrews-MailScanner-SpamCheck | not spam, SpamAssassin (not cached, score=-0.01, required 5, autolearn=not spam, DKIM_SIGNED 0.10, DKIM_VALID -0.10, T_DKIMWL_WL_MED -0.01) |
| X-StAndrews-MailScanner | No virus detected |
| X-StAndrews-MailScanner-ID | wAE9momO024533 |
| X-StAndrews-MailScanner-Information | Please contact the ISP for more information |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=UniversityofStAndrews907.onmicrosoft.com; s=selector1-standrews-ac-uk0e; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=SkPBsmP4xzt0ReYM3BZ3D68Peu8KhYEoJD3xJHpF5SA=; b=IchHTRy9HFLE8M1mdRARinGxYiARRbrJKpEBaUPgo4FcDJaXP+CCr3aAlbTRF3A1SKGWexZD4yOq+2nJZVQbemD35hWWAqfy7Pl+/Yg7flWzJ54IhmB+T9VgBcsyV6O/Zuiz86Liow36KkUvzvB/Qb9zPN82w+X+yl4S79q3rsM= |
| Thread-Topic | Strange behaviour from jobs -p in a subshell |
| Thread-Index | AQHUezNGF5NWxcZ52ESE8KdIIpAeM6VNzKeAgAE7bIA= |
| In-Reply-To | <563c6188-c905-db81-f330-b79bf17e4413@case.edu> |
| Accept-Language | en-GB, en-US |
| Content-Language | en-US |
| X-MS-Has-Attach | |
| X-MS-TNEF-Correlator | |
| user-agent | Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.2.1 |
| x-clientproxiedby | DB6PR0801CA0044.eurprd08.prod.outlook.com (2603:10a6:4:2b::12) To DB6PR0601MB2661.eurprd06.prod.outlook.com (2603:10a6:4:6e::14) |
| authentication-results | spf=none (sender IP is ) smtp.mailfrom=caj21@st-andrews.ac.uk; |
| x-ms-exchange-messagesentrepresentingtype | 1 |
| x-originating-ip | [138.251.253.133] |
| x-ms-publictraffictype | |
| x-microsoft-exchange-diagnostics | 1; DB6PR0601MB2197; 6:3ZsDUDio7cpQ7yaqxy89FNW+X42AZwX9G0Io4asa6XPApW0cUosn9j/Kp0m26g1/yJVq56JJevZHKeLNWggqYQcxloUvdIcsvheF1igwSbWmpbZKYyrvMJQ6sbJX0QU1KeP2ZctvLVAgxMJJJwKKXkZbkDbl0Lxzldx68s45qSt6C5DzYyjd91ee1hM1yl0PBh5ZomrIxHroPT/4qSavDYItsn/6XVrjcEdVUX5+qpRoPm+sKYtY9W2koiY2NVh7J19Ogyyvq26yPVPKE+V9Y4B26Q4boHB5aW17y+jfSUEOLI+GZsoGKa3UDSXNtkhvQJ6FXcyzztrdsyxItg2RIcobnVNmwd17Tv7zCbFBmuh9KsM67hdzC2wvD9wLjTGxd0XKjB8whppZ0OPZBhFv//fVcfoTSgFljEW1r3yf9obuKFuSU+IFIwqJK7kDE5uXxkVs4ud9wRL6vV+VqSjYxg==; 5:d85ZKHR95zAP5fnKY4rMsCSmYbOYkjODMVzNaS8dL+b3VHI7KDcwXizrgg8/NW2D3eUx2VZWGXpvJKZ9sFuj/IbbiPO9Z7J8QhFOrhWW99m7TxUw0BHqDj0a6vLqlv2DsC3LusBkGK3csjgRcInIrxCJWOy2GjbHe91pxhZlSYw=; 7:iT9oXFJr6HQMbs0CZogMmfRCQCWGEJwbJZo+M+p13OgZullh8rIjhan17ozT8bs+XrzppO66kfOr5rh8wcJHOol+utGl7JaqsBHwAEOceCmY3gAfprKplxHP+NSzsZJY7jkQC9POkzkD4LcULb/73Q== |
| x-ms-office365-filtering-correlation-id | 4cfe5283-3a9e-45bf-7e99-08d64a166090 |
| x-microsoft-antispam | BCL:0; PCL:0; RULEID:(2390098)(7020095)(4652040)(8989299)(4534185)(4627221)(201703031133081)(201702281549075)(8990200)(5600074)(711020)(2017052603328)(7153060)(7193020); SRVR:DB6PR0601MB2197; |
| x-ms-traffictypediagnostic | DB6PR0601MB2197: |
| x-microsoft-antispam-prvs | <DB6PR0601MB219783CB8FEE80EF757F08E8DFC30@DB6PR0601MB2197.eurprd06.prod.outlook.com> |
| x-exchange-antispam-report-test | UriScan:; |
| x-ms-exchange-senderadcheck | 1 |
| x-exchange-antispam-report-cfa-test | BCL:0; PCL:0; RULEID:(8211001083)(6040522)(2401047)(5005006)(8121501046)(3231410)(944501410)(52105112)(10201501046)(93006095)(93001095)(3002001)(148016)(149066)(150057)(6041310)(20161123562045)(20161123560045)(20161123564045)(201703131423095)(201702281529075)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123558120)(201708071742011)(7699051)(76991095); SRVR:DB6PR0601MB2197; BCL:0; PCL:0; RULEID:; SRVR:DB6PR0601MB2197; |
| x-forefront-prvs | 085634EFF4 |
| x-forefront-antispam-report | SFV:NSPM; SFS:(10019020)(376002)(39860400002)(136003)(346002)(366004)(396003)(189003)(199004)(6512007)(6116002)(68736007)(53546011)(5660300001)(102836004)(52116002)(6246003)(76176011)(53936002)(3846002)(2906002)(31696002)(31686004)(86362001)(2501003)(6506007)(386003)(64126003)(256004)(74482002)(26005)(65826007)(2171002)(186003)(97736004)(65806001)(316002)(66066001)(81166006)(8676002)(81156014)(8936002)(71190400001)(71200400001)(6436002)(486006)(105586002)(6486002)(229853002)(478600001)(11346002)(446003)(476003)(14454004)(2616005)(58126008)(36756003)(305945005)(99286004)(25786009)(2900100001)(106356001)(7736002)(110136005)(786003)(65956001)(42262002); DIR:OUT; SFP:1102; SCL:1; SRVR:DB6PR0601MB2197; H:DB6PR0601MB2661.eurprd06.prod.outlook.com; FPR:; SPF:None; LANG:en; PTR:InfoNoRecords; MX:1; A:1; |
| received-spf | None (protection.outlook.com: st-andrews.ac.uk does not designate permitted sender hosts) |
| x-microsoft-antispam-message-info | +dldyPTUUmwGSR4nKL3TAhU+q6r39ve6YnBAUJCGJlz0wzVLXMMejU343f+MwYLwuRak7gEI871SyKCa0Yn4Y54fSZN/tYIfstHBQI/QzGN6wicbjNv1zAcApYowbf3hCrEKjPmLNMwWGq7+VCJHlKqSE2thJttvYpVC6Nltw1p2wb4tJw7HZ1ssPLMFGKW/He6cpQ4ECWRp2rysbijNxuzb01LpeG6WIkqpAeCULPej2J6qSG4FHQFjgW7+7ZML9QDKbIdcUupTt7c38X99Dq2kyeJvQnigOlaFdlMp2ILMZ8ncVXmwH1gk8mUbtK30ewTBW57ZO5oeCUrekj9y0CWA5CF8VOmniqUS4zKGjj8= |
| spamdiagnosticoutput | 1:99 |
| spamdiagnosticmetadata | NSPM |
| Content-ID | <2A4881B1EDFC7E44877E6D7BD4A25B97@eurprd06.prod.outlook.com> |
| X-MS-Exchange-CrossTenant-Network-Message-Id | 4cfe5283-3a9e-45bf-7e99-08d64a166090 |
| X-MS-Exchange-CrossTenant-originalarrivaltime | 14 Nov 2018 09:48:49.2915 (UTC) |
| X-MS-Exchange-CrossTenant-fromentityheader | Hosted |
| X-MS-Exchange-CrossTenant-id | f85626cb-0da8-49d3-aa58-64ef678ef01a |
| X-MS-Exchange-Transport-CrossTenantHeadersStamped | DB6PR0601MB2197 |
| X-detected-operating-system | by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] |
| X-Received-From | 138.251.6.248 |
| X-BeenThere | bug-bash@gnu.org |
| X-Mailman-Version | 2.1.21 |
| Precedence | list |
| List-Id | Bug reports for the GNU Bourne Again SHell <bug-bash.gnu.org> |
| List-Unsubscribe | <https://lists.gnu.org/mailman/options/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=unsubscribe> |
| List-Archive | <http://lists.gnu.org/archive/html/bug-bash/> |
| List-Post | <mailto:bug-bash@gnu.org> |
| List-Help | <mailto:bug-bash-request@gnu.org?subject=help> |
| List-Subscribe | <https://lists.gnu.org/mailman/listinfo/bug-bash>, <mailto:bug-bash-request@gnu.org?subject=subscribe> |
| Xref | csiph.com gnu.bash.bug:14818 |
Show key headers only | View raw
On 13/11/2018 14:59, Chet Ramey wrote: > On 11/13/18 4:28 AM, Christopher Jefferson wrote: >> Consider the following script. While the 3 sleeps are running, both jobs >> -p and $(jobs -p) will print 3 PIDs. Once the 3 children are finished, >> jobs -p will continue to print the 3 PIDs of the done Children, but >> $(jobs -p) will only print 1 PID. $(jobs -p) always seems to print at >> most 1 PID of a done child. > Since the $(jobs -p) is run in a subshell, its knowledge of its parent's > jobs is transient. In this case, the subshell deletes knowledge of the > jobs it inherits from its parent, but hangs onto the last asynchronous job > in case the subshell references $!. Is this a case of "works as intended" then? I find the current behaviour very strange -- I could understand if 'jobs -p' showed no information about processes spawned from the parent shell, or all of it, but the current position seems quite inconsistent. This originally came up as I was implementing a poor way of limiting how many background processes I spawn, by doing: while (( $(jobs -p | wc -l) >= $JOBCOUNT )) do sleep 1 done Here, the $(jobs -p | wc -l) decreases to 1 as jobs finish, but never reaches 0. I've now changed 'sleep 1' to 'jobs > /dev/null; sleep 1'. I can't find any documentation that says this, but it seems 'jobs' will clean up children which are done, which 'jobs -p' does not (this makes sense of course, as jobs -p doesn't report if a child is done, but I still can't find it documented anywhere). Chris
Back to gnu.bash.bug | Previous | Next | Find similar | Unroll thread
Re: Strange behaviour from jobs -p in a subshell Christopher Jefferson <caj21@st-andrews.ac.uk> - 2018-11-14 09:48 +0000
csiph-web