[macruby-changes] [1835] MacRuby/branches/experimental/io.c
source_changes at macosforge.org
source_changes at macosforge.org
Thu Jun 11 10:22:38 PDT 2009
Revision: 1835
http://trac.macosforge.org/projects/ruby/changeset/1835
Author: pthomson at apple.com
Date: 2009-06-11 10:22:38 -0700 (Thu, 11 Jun 2009)
Log Message:
-----------
Implemented IO#close_on_exec. Are there specs for this?
Modified Paths:
--------------
MacRuby/branches/experimental/io.c
Modified: MacRuby/branches/experimental/io.c
===================================================================
--- MacRuby/branches/experimental/io.c 2009-06-11 16:53:29 UTC (rev 1834)
+++ MacRuby/branches/experimental/io.c 2009-06-11 17:22:38 UTC (rev 1835)
@@ -1739,7 +1739,9 @@
static VALUE
rb_io_close_on_exec_p(VALUE io, SEL sel)
{
- rb_notimplement();
+ rb_io_t *io_s = ExtractIOStruct(io);
+ int flags = fcntl(io_s->fd, F_GETFD, 0);
+ return ((flags & FD_CLOEXEC) ? Qtrue : Qfalse);
}
/*
@@ -1757,7 +1759,16 @@
static VALUE
rb_io_set_close_on_exec(VALUE io, SEL sel, VALUE arg)
{
- rb_notimplement();
+ rb_io_t *io_s = ExtractIOStruct(io);
+ int flags = fcntl(io_s->fd, F_GETFD, 0);
+ if (arg == Qtrue) {
+ flags |= FD_CLOEXEC;
+ }
+ else {
+ flags &= ~FD_CLOEXEC;
+ }
+ fcntl(io_s->fd, F_SETFD, flags);
+ return arg;
}
static inline void
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20090611/e9c1474d/attachment.html>
More information about the macruby-changes
mailing list