zsh-workers
 help / color / mirror / code / Atom feed
* [PATCH] bin_umask(): Queue signals around umask().
@ 2020-01-14 19:09 Daniel Shahaf
  0 siblings, 0 replies; only message in thread
From: Daniel Shahaf @ 2020-01-14 19:09 UTC (permalink / raw)
  To: zsh-workers

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

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2020-01-14 19:10 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-01-14 19:09 [PATCH] bin_umask(): Queue signals around umask() Daniel Shahaf

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).