aboutsummaryrefslogtreecommitdiffstats
path: root/io.c
diff options
context:
space:
mode:
authorko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-20 10:47:53 +0000
committerko1 <ko1@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2007-11-20 10:47:53 +0000
commit3453b2bd0e186788bb81deff5d723cf48e10881f (patch)
tree329d42bdbd0d45463caf6b6f3c67c9443f9153be /io.c
parentd481323b9211cc0823fba407253d0432fa7f1734 (diff)
downloadruby-3453b2bd0e186788bb81deff5d723cf48e10881f.tar.gz
* gc.h, vm_core.h: decl of rb_gc_save_machine_context()
should be at vm_core.h. * include/ruby/ruby.h, intern.h: remove type rb_thread_t. * include/ruby/intern.h: change rb_unblock_function_t, rb_unblock_function_t. * file.c, process.c: apply above changes. * thread.c, thread_pthread.ci, thread_win32.ci: ditto. * io.c: support blocking open (2). [ruby-core:13614] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@13984 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'io.c')
-rw-r--r--io.c24
1 files changed, 22 insertions, 2 deletions
diff --git a/io.c b/io.c
index 7b9b487318..677c3cab1c 100644
--- a/io.c
+++ b/io.c
@@ -3015,16 +3015,36 @@ rb_io_modenum_mode(int flags)
return NULL; /* not reached */
}
+struct sysopen_struct {
+ char *fname;
+ int flag;
+ unsigned int mode;
+};
+
+static VALUE
+sysopen_func(void *ptr)
+{
+ struct sysopen_struct *data = ptr;
+ return (VALUE)open(data->fname, data->flag, data->mode);
+}
+
+static int
+rb_sysopen_internal(char *fname, int flags, unsigned int mode)
+{
+ struct sysopen_struct data = {fname, flags, mode};
+ return (int)rb_thread_blocking_region(sysopen_func, &data, RB_UBF_DFL, 0);
+}
+
static int
rb_sysopen(char *fname, int flags, unsigned int mode)
{
int fd;
- fd = open(fname, flags, mode);
+ fd = rb_sysopen_internal(fname, flags, mode);
if (fd < 0) {
if (errno == EMFILE || errno == ENFILE) {
rb_gc();
- fd = open(fname, flags, mode);
+ fd = rb_sysopen_internal(fname, flags, mode);
}
if (fd < 0) {
rb_sys_fail(fname);