Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

[PATCH] bin_umask(): Queue signals around umask().



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



Messages sorted by: Reverse Date, Date, Thread, Author