1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

process.c: no method calls in async-signal-safe

* process.c (rb_execarg_run_options): do not call any methods in the
  async-signal-safe function.  mask has been checked with NUM2MODET()
  already and converted with LONG2NUM().


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36134 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-06-19 08:51:57 +00:00
parent 6696fd0c49
commit 52b497d8b7
2 changed files with 10 additions and 1 deletions

View file

@ -1,3 +1,9 @@
Tue Jun 19 17:51:54 2012 Nobuyoshi Nakada <nobu@ruby-lang.org>
* process.c (rb_execarg_run_options): do not call any methods in the
async-signal-safe function. mask has been checked with NUM2MODET()
already and converted with LONG2NUM().
Tue Jun 19 11:59:56 2012 NARUSE, Yui <naruse@ruby-lang.org>
* ext/readline/readline.c (Init_readline): don't set 0 to

View file

@ -17,6 +17,8 @@
#include "internal.h"
#include "vm_core.h"
#define STATIC_ASSERT(name, expr) typedef int static_assert_##name##_check[1 - 2*!(expr)]
#include <stdio.h>
#include <errno.h>
#include <signal.h>
@ -1595,6 +1597,7 @@ rb_execarg_addopt(struct rb_exec_arg *e, VALUE key, VALUE val)
hide_obj(rb_str_dup(val)));
}
else if (id == rb_intern("umask")) {
STATIC_ASSERT(sizeof_mode_t, sizeof(long) >= sizeof(mode_t)); /* for LONG2NUM */
mode_t cmask = NUM2MODET(val);
if (!NIL_P(rb_ary_entry(options, EXEC_OPTION_UMASK))) {
rb_raise(rb_eArgError, "umask option specified twice");
@ -2707,7 +2710,7 @@ rb_execarg_run_options(const struct rb_exec_arg *e, struct rb_exec_arg *s, char
obj = rb_ary_entry(options, EXEC_OPTION_UMASK);
if (!NIL_P(obj)) {
mode_t mask = NUM2MODET(obj);
mode_t mask = (mode_t)FIX2LONG(obj); /* no method calls */
mode_t oldmask = umask(mask); /* never fail */ /* async-signal-safe */
if (!NIL_P(soptions))
rb_ary_store(soptions, EXEC_OPTION_UMASK, MODET2NUM(oldmask));