diff --git a/ChangeLog b/ChangeLog index 37858c2b86..a748fd6b6c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Thu Nov 3 22:12:41 2011 CHIKANAGA Tomoyuki + + * ext/socket/init.c (rsock_socket): set close-on-exec flag when + SOCK_CLOEXEC is not available. + Thu Nov 03 08:36:00 2011 Martin Bosslet * test/openssl/test_engine.rb: call Engine::cleanup on exit. diff --git a/ext/socket/init.c b/ext/socket/init.c index ad25ccb080..92cca7c057 100644 --- a/ext/socket/init.c +++ b/ext/socket/init.c @@ -270,8 +270,16 @@ rsock_socket(int domain, int type0, int proto) fd = socket(domain, type, proto); } } +#ifdef SOCK_CLOEXEC if (0 <= fd) - rb_update_max_fd(fd); + if (try_sock_cloexec) + rb_update_max_fd(fd); + else + rb_fd_fix_cloexec(fd); +#else + if (0 <= fd) + rb_fd_fix_cloexec(fd); +#endif return fd; }