ruby-changes:24143
From: akr <ko1@a...>
Date: Sat, 23 Jun 2012 13:23:17 +0900 (JST)
Subject: [ruby-changes:24143] akr:r36194 (trunk): * internal.h (rb_execarg): add close_others_given, close_others_do and
akr 2012-06-23 13:23:03 +0900 (Sat, 23 Jun 2012) New Revision: 36194 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=36194 Log: * internal.h (rb_execarg): add close_others_given, close_others_do and close_others_maxhint fields. * process.c (EXEC_OPTION_CLOSE_OTHERS): removed. (rb_execarg_addopt): update the new fields, instead of options array. (check_exec_fds): take eargp as an argument. update the close_others_maxhint field. (rb_execarg_fixup): follow the argument change of check_exec_fds. (rb_execarg_run_options): use the new fields. Modified files: trunk/ChangeLog trunk/internal.h trunk/process.c Index: ChangeLog =================================================================== --- ChangeLog (revision 36193) +++ ChangeLog (revision 36194) @@ -1,3 +1,15 @@ +Sat Jun 23 13:20:47 2012 Tanaka Akira <akr@f...> + + * internal.h (rb_execarg): add close_others_given, close_others_do and + close_others_maxhint fields. + + * process.c (EXEC_OPTION_CLOSE_OTHERS): removed. + (rb_execarg_addopt): update the new fields, instead of options array. + (check_exec_fds): take eargp as an argument. update the + close_others_maxhint field. + (rb_execarg_fixup): follow the argument change of check_exec_fds. + (rb_execarg_run_options): use the new fields. + Sat Jun 23 10:41:59 2012 Tanaka Akira <akr@f...> * internal.h (rb_execarg): add unsetenv_others_given and Index: process.c =================================================================== --- process.c (revision 36193) +++ process.c (revision 36194) @@ -1261,7 +1261,6 @@ EXEC_OPTION_CLOSE, EXEC_OPTION_OPEN, EXEC_OPTION_DUP2_CHILD, - EXEC_OPTION_CLOSE_OTHERS, EXEC_OPTION_NEW_PGROUP }; @@ -1639,11 +1638,11 @@ eargp->umask_mask = cmask; } else if (id == rb_intern("close_others")) { - if (!NIL_P(rb_ary_entry(options, EXEC_OPTION_CLOSE_OTHERS))) { + if (eargp->close_others_given) { rb_raise(rb_eArgError, "close_others option specified twice"); } - val = RTEST(val) ? Qtrue : Qfalse; - rb_ary_store(options, EXEC_OPTION_CLOSE_OTHERS, val); + eargp->close_others_given = 1; + eargp->close_others_do = RTEST(val) ? 1 : 0; } else if (id == rb_intern("in")) { key = INT2FIX(0); @@ -1694,8 +1693,9 @@ } static VALUE -check_exec_fds(VALUE options) +check_exec_fds(struct rb_execarg *eargp) { + VALUE options = eargp->options; VALUE h = rb_hash_new(); VALUE ary; int index, maxhint = -1; @@ -1758,9 +1758,7 @@ } } - if (rb_ary_entry(options, EXEC_OPTION_CLOSE_OTHERS) != Qfalse) { - rb_ary_store(options, EXEC_OPTION_CLOSE_OTHERS, INT2FIX(maxhint)); - } + eargp->close_others_maxhint = maxhint; return h; } @@ -2119,7 +2117,7 @@ VALUE envopts; VALUE ary; - eargp->redirect_fds = check_exec_fds(eargp->options); + eargp->redirect_fds = check_exec_fds(eargp); ary = rb_ary_entry(eargp->options, EXEC_OPTION_DUP2); if (!NIL_P(ary)) { @@ -2803,9 +2801,8 @@ } #ifdef HAVE_FORK - obj = rb_ary_entry(options, EXEC_OPTION_CLOSE_OTHERS); - if (obj != Qfalse) { - rb_close_before_exec(3, FIX2INT(obj), eargp->redirect_fds); /* async-signal-safe */ + if (!eargp->close_others_given || eargp->close_others_do) { + rb_close_before_exec(3, eargp->close_others_maxhint, eargp->redirect_fds); /* async-signal-safe */ } #endif Index: internal.h =================================================================== --- internal.h (revision 36193) +++ internal.h (revision 36194) @@ -180,8 +180,11 @@ unsigned umask_given : 1; unsigned unsetenv_others_given : 1; unsigned unsetenv_others_do : 1; + unsigned close_others_given : 1; + unsigned close_others_do : 1; pid_t pgroup_pgid; /* asis(-1), new pgroup(0), specified pgroup (0<V). */ mode_t umask_mask; + int close_others_maxhint; }; /* argv_str contains extra two elements. -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/