zsh-workers
 help / color / 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, back to index

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

zsh-workers

Archives are clonable: git clone --mirror http://inbox.vuxu.org/zsh-workers

Example config snippet for mirrors

Newsgroup available over NNTP:
	nntp://inbox.vuxu.org/vuxu.archive.zsh.workers


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git