From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 10508 invoked by alias); 12 Sep 2016 17:34:10 -0000 Mailing-List: contact zsh-users-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Users List List-Post: List-Help: X-Seq: 21878 Received: (qmail 23339 invoked from network); 12 Sep 2016 17:34:10 -0000 X-Qmail-Scanner-Diagnostics: from mail-qk0-f182.google.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.99.2/21882. spamassassin: 3.4.1. Clear:RC:0(209.85.220.182):SA:0(0.0/5.0):. Processed in 0.318097 secs); 12 Sep 2016 17:34:10 -0000 X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=FREEMAIL_FROM,SPF_PASS, T_DKIM_INVALID autolearn=unavailable autolearn_force=no version=3.4.1 X-Envelope-From: sgniazdowski@gmail.com X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: pass (ns1.primenet.com.au: SPF record at _netblocks.google.com designates 209.85.220.182 as permitted sender) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=LVwlE6qvWNGTMc7vH/6DUxAvrk6q7RnQp8z8kyDUaTU=; b=tlHaL7AkDYH/MnIUGEiDYMwFqqO/DQ5JPSfpbmD6RsU8VVo3IJASG1ydLntOVi1bYI Avjv45bKw9KpfWpAeY9vgKg4FOSTH/0+P4iSFfKCvjW8mGkAp4DUi4TcZheUcmZLyq4u 99qR0c0v/c0KvqzdTQ+5MWI9ZmNymF2jB2Ujn5XpkxlWllhhIs+PlPLCPwlvXDPwHRh1 MSSighea8UrO9dcA0L3y04g6rw3FyvC1/FmMrH7/BHmIwEB/jDVs20MRglZZevLlIaV4 eCxI6BUgloGnkI/wWra50Y4Nr8QhOYJFix97YhdprmOpa1LEIcAKKadG0G3SYdLCzewP kPfA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=LVwlE6qvWNGTMc7vH/6DUxAvrk6q7RnQp8z8kyDUaTU=; b=WLVUq4+NjIUzTUVXsYVBJIx0Ku/GLM7Yn09KWZF7qUPvugSRnjhplUjYRRyFP6tYDh 1mp53Ow8l9cn9DUsocmJeDkvas+NR84Qlghb3Mk6bq7jlz8iyTF7Mbg1n2jyGad11BLi LaeOdjEoeiAD56uCy2y0ohuVvMGBhhzRVhh2h+u0ABJ7AGDnJugqJXTLL/GY1WtvSXx5 oXC+v9454ECcYOYHUIgvePwDMyD1EHtzwlq3kdAyls0pRYY4eo4nLaF0GG71KYfMJC4l 6fK30vjMBJvdpPsgmtoRA4JrqFoQegVAJl1FmsHhfYvY99DQCrUzJE7njY4YOZWw3Yrt nV/w== X-Gm-Message-State: AE9vXwMrKx1MW/U3UC1ZVEgjUtUrWuJVQrvVdJ4z3Au0FuV5HjAgaGR/mqhbcnGaoNYS9fsuRbKkywvTUFQqpg== X-Received: by 10.55.41.198 with SMTP id p67mr19357747qkp.217.1473697818830; Mon, 12 Sep 2016 09:30:18 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: <20160912171959.2516a91e@pwslap01u.europe.root.pri> References: <20160912171959.2516a91e@pwslap01u.europe.root.pri> From: Sebastian Gniazdowski Date: Mon, 12 Sep 2016 18:29:58 +0200 Message-ID: Subject: Re: Do file descriptors survive to subshell? To: Peter Stephenson Cc: Zsh Users Content-Type: text/plain; charset=UTF-8 OK, thanks. I was planning to use read -t -u on a descriptor obtained by exported variable SOMETHING_ID, to differentiate between `exec zsh-5.2-dev-1` and `zsh-5.2-dev-1`. If it would fail then it's non-exec, regular start. Now I see that SHLVL should be used to differentiate that? BTW., read -t -u seems to succeed as many times as there are lines in a file (file descriptor), that's rather unexpected, it rather should do some "read char, put char back" thing, or something not changing FD position in file I would say Best regards, Sebastian Gniazdowski On 12 September 2016 at 18:19, Peter Stephenson wrote: > It depends how the FD was opened. > >> But the "survive FD" feature should work only for >> "exec zsh-5.2-dev-1", not "zsh-5.2-dev-1", shouldn't it ... > > well, if you ran > > zsh-5.2-dev-1 3< myfile > > you'd be a bit annoyed if FD 3 was closed, wouldn't you? > And of course 0, 1 and 2 are left open. > > So for FDs opened by / known to the user, it's expected that they'll > survive; internal FDs used by the shell should be closed. One example > of an FD the shell uses internally is for terminal management --- we > don't do this directly on the user-visible FDs for reasons I don't > think I ever fully understood. Because this is opened early, it's > usualy FD 10, i.e. just outside the easily accessible range (that > traditionally shells keep away from allowing you to manipulate > directly) 0 to 9. > > pws