ruby-changes:21500
From: akr <ko1@a...>
Date: Sat, 29 Oct 2011 11:33:42 +0900 (JST)
Subject: [ruby-changes:21500] akr:r33549 (trunk): * include/ruby/intern.h (rb_cloexec_open): declared.
akr 2011-10-29 11:33:28 +0900 (Sat, 29 Oct 2011) New Revision: 33549 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=33549 Log: * include/ruby/intern.h (rb_cloexec_open): declared. * io.c (fd_set_cloexec): extracted from rb_fd_set_cloexec. (rb_cloexec_open): new function. (sysopen_func): use rb_cloexec_open. (rb_sysopen_internal): use rb_update_max_fd instead of rb_fd_set_cloexec. Modified files: trunk/ChangeLog trunk/include/ruby/intern.h trunk/io.c Index: include/ruby/intern.h =================================================================== --- include/ruby/intern.h (revision 33548) +++ include/ruby/intern.h (revision 33549) @@ -502,6 +502,7 @@ void rb_close_before_exec(int lowfd, int maxhint, VALUE noclose_fds); int rb_pipe(int *pipes); int rb_reserved_fd_p(int fd); +int rb_cloexec_open(const char *pathname, int flags, mode_t mode); #define RB_RESERVED_FD_P(fd) rb_reserved_fd_p(fd) void rb_update_max_fd(int fd); void rb_fd_set_cloexec(int fd); Index: ChangeLog =================================================================== --- ChangeLog (revision 33548) +++ ChangeLog (revision 33549) @@ -1,3 +1,13 @@ +Sat Oct 29 10:40:19 2011 Tanaka Akira <akr@f...> + + * include/ruby/intern.h (rb_cloexec_open): declared. + + * io.c (fd_set_cloexec): extracted from rb_fd_set_cloexec. + (rb_cloexec_open): new function. + (sysopen_func): use rb_cloexec_open. + (rb_sysopen_internal): use rb_update_max_fd instead of + rb_fd_set_cloexec. + Sat Oct 29 09:05:07 2011 Nobuyoshi Nakada <nobu@r...> * thread_pthread.h: no Structured Exception Handling like macros. Index: io.c =================================================================== --- io.c (revision 33548) +++ io.c (revision 33549) @@ -157,7 +157,8 @@ if (max_file_descriptor < fd) max_file_descriptor = fd; } -void rb_fd_set_cloexec(int fd) +static void +fd_set_cloexec(int fd) { /* MinGW don't have F_GETFD and FD_CLOEXEC. [ruby-core:40281] */ #ifdef F_GETFD @@ -176,9 +177,27 @@ } } #endif +} + +void +rb_fd_set_cloexec(int fd) +{ + fd_set_cloexec(fd); if (max_file_descriptor < fd) max_file_descriptor = fd; } + +int +rb_cloexec_open(const char *pathname, int flags, mode_t mode) +{ + int ret; + ret = open(pathname, flags, mode); + if (ret == -1) return -1; + fd_set_cloexec(ret); + return ret; +} + + #define argf_of(obj) (*(struct argf *)DATA_PTR(obj)) #define ARGF argf_of(argf) @@ -4604,7 +4623,7 @@ { const struct sysopen_struct *data = ptr; const char *fname = RSTRING_PTR(data->fname); - return (VALUE)open(fname, data->oflags, data->perm); + return (VALUE)rb_cloexec_open(fname, data->oflags, data->perm); } static inline int @@ -4613,7 +4632,7 @@ int fd; fd = (int)rb_thread_blocking_region(sysopen_func, data, RUBY_UBF_IO, 0); if (0 <= fd) - rb_fd_set_cloexec(fd); + rb_update_max_fd(fd); return fd; } -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/