zsh-workers
 help / color / mirror / code / Atom feed
From: Daniel Shahaf <danielsh@apache.org>
To: zsh-workers@zsh.org
Subject: [PATCH] bin_umask(): Queue signals around umask().
Date: Tue, 14 Jan 2020 19:09:54 +0000	[thread overview]
Message-ID: <20200114190954.27376-1-danielsh@apache.org> (raw)

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')) {

                 reply	other threads:[~2020-01-14 19:10 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200114190954.27376-1-danielsh@apache.org \
    --to=danielsh@apache.org \
    --cc=zsh-workers@zsh.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/zsh/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).