From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, RCVD_IN_DNSWL_NONE autolearn=ham autolearn_force=no version=3.4.2 Received: from primenet.com.au (ns1.primenet.com.au [203.24.36.2]) by inbox.vuxu.org (OpenSMTPD) with ESMTP id e75439b6 for ; Tue, 14 Jan 2020 19:10:57 +0000 (UTC) Received: (qmail 16849 invoked by alias); 14 Jan 2020 19:10:36 -0000 Mailing-List: contact zsh-workers-help@zsh.org; run by ezmlm Precedence: bulk X-No-Archive: yes List-Id: Zsh Workers List List-Post: List-Help: List-Unsubscribe: X-Seq: 45302 Received: (qmail 19612 invoked by uid 1010); 14 Jan 2020 19:10:36 -0000 X-Qmail-Scanner-Diagnostics: from wout4-smtp.messagingengine.com by f.primenet.com.au (envelope-from , uid 7791) with qmail-scanner-2.11 (clamdscan: 0.102.1/25691. spamassassin: 3.4.2. Clear:RC:0(64.147.123.20):SA:0(-1.9/5.0):. Processed in 4.688731 secs); 14 Jan 2020 19:10:36 -0000 X-Envelope-From: danielsh@apache.org X-Qmail-Scanner-Mime-Attachments: | X-Qmail-Scanner-Zip-Files: | Received-SPF: softfail (ns1.primenet.com.au: transitioning SPF record at amazonses.com does not designate 64.147.123.20 as permitted sender) X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedugedrtddugddvkecutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecunecujfgurhephffvufffkffoggfgsedtkeertdertd dtnecuhfhrohhmpeffrghnihgvlhcuufhhrghhrghfuceouggrnhhivghlshhhsegrphgr tghhvgdrohhrgheqnecukfhppeejledrudektddrheejrdduudelnecurfgrrhgrmhepmh grihhlfhhrohhmpegurghnihgvlhhshhesrghprggthhgvrdhorhhgnecuvehluhhsthgv rhfuihiivgeptd X-ME-Proxy: From: Daniel Shahaf To: zsh-workers@zsh.org Subject: [PATCH] bin_umask(): Queue signals around umask(). Date: Tue, 14 Jan 2020 19:09:54 +0000 Message-Id: <20200114190954.27376-1-danielsh@apache.org> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Qmail-Scanner-2.11: added fake Content-Type header Content-Type: text/plain Otherwise, a signal handler might create files while the temporary umask is in effect. --- Question. The umask(2) syscall appeared in 1979, according to FreeBSD + Wikipedia. That's 40 years ago. How come that there isn't a non-destructive getter for the process's current umask value yet? It's on my list to make the same change for arithmetic evaluation. I think queueing should be placed in mathparse(), but I need to review that again. Cheers, Daniel Src/builtin.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/Src/builtin.c b/Src/builtin.c index dc1d6323e..b2b7a92f6 100644 --- a/Src/builtin.c +++ b/Src/builtin.c @@ -7298,8 +7298,11 @@ bin_umask(char *nam, char **args, Options ops, UNUSED(int func)) char *s = *args; /* Get the current umask. */ - um = umask(0); + queue_signals(); + um = umask(0777); umask(um); + unqueue_signals(); + /* No arguments means to display the current setting. */ if (!s) { if (OPT_ISSET(ops,'S')) {