[#9642] Re: host.conf は参照しないの? — akira yamada / やまだあきら <akira@...>

15 messages 2000/05/09

[#9672] IO.popen — Koji Arai <JCA02266@...>

新井です。

22 messages 2000/05/13
[#9673] Re: IO.popen — Koji Arai <JCA02266@...> 2000/05/13

新井です。

[#9682] Re: IO.popen — matz@... (Yukihiro Matsumoto) 2000/05/14

まつもと ゆきひろです

[#9676] support mingw32 — WATANABE Hirofumi <eban@...>

わたなべです.

32 messages 2000/05/13
[#9678] Re: support mingw32 — Masaki Suketa <CQN02273@...> 2000/05/14

助田です.

[#9680] Re: support mingw32 — WATANABE Hirofumi <eban@...> 2000/05/14

わたなべです.

[#9686] Re: support mingw32 — Katsuyuki Komatsu <komatsu@...> 2000/05/15

小松です。

[#9687] Re: support mingw32 — WATANABE Hirofumi <Hirofumi.Watanabe@...> 2000/05/15

わたなべです.

[#9806] rescue variable syntax — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

40 messages 2000/05/24
[#9811] Re: rescue variable syntax — ARIMA Yasuhiro <fit0298@...> 2000/05/24

有馬です。

[#9814] Re: rescue variable syntax — matz@... (Yukihiro Matsumoto) 2000/05/24

まつもと ゆきひろです

[#9821] Re: rescue variable syntax — nobu.nakada@... 2000/05/25

なかだです。

[#9823] Re: rescue variable syntax — ARIMA Yasuhiro <fit0298@...> 2000/05/25

有馬です。

[#9833] Re: rescue variable syntax — matz@... (Yukihiro Matsumoto) 2000/05/25

まつもと ゆきひろです

[#9861] Re: rescue variable syntax — gotoken@... (GOTO Kentaro) 2000/05/25

ごとけんです

[#9866] Re: rescue variable syntax — matz@... (Yukihiro Matsumoto) 2000/05/25

まつもと ゆきひろです

[#9870] Re: rescue variable syntax — nagai@... 2000/05/26

永井@知能.九工大です.

[#9873] Re: rescue variable syntax — matz@... (Yukihiro Matsumoto) 2000/05/27

まつもと ゆきひろです

[#9812] Forward: Error in NT makefile (PR#7) — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

21 messages 2000/05/24
[#9820] Re: Forward: Error in NT makefile (PR#7) — Katsuyuki Komatsu <komatsu@...> 2000/05/25

小松です。

[#9842] Re: Forward: Error in NT makefile (PR#7) — WATANABE Hirofumi <Hirofumi.Watanabe@...> 2000/05/25

わたなべです.

[#9855] Re: Forward: Error in NT makefile (PR#7) — Katsuyuki Komatsu <komatsu@...> 2000/05/25

小松です。

[#9879] Re: Forward: Error in NT makefile (PR#7) — WATANABE Hirofumi <eban@...> 2000/05/28

わたなべです.

[#9857] $0 handling on NT — Katsuyuki Komatsu <komatsu@...>

小松です。

18 messages 2000/05/25
[#9869] Re: $0 handling on NT — nobu.nakada@... 2000/05/26

なかだです。

[ruby-dev:9738] Re: IO.popen

From: nobu.nakada@...
Date: 2000-05-17 09:03:59 UTC
List: ruby-dev #9738
なかだです。

At Tue, 16 May 2000 23:07:47 +0900,
nobu.nakada@nifty.ne.jp wrote:
> > pidってメソッドを追加する? で、pipeでなければnilを返す(また
> > は例外、どっちが良いか)では?
> 
>   ほんとだったら例外の方がいいのかも知れませんが、決まってるも
> のなのに呼んでみるまで知る術がないってところがワナっぽくてなん
> となくいやん。

  IO#tty? とかもあることだし、IO#pipe? とかと二段構えの作戦にすればい
いかも。

--- IO#pipe?
    returns (({pid})) if (({popen}))ed, otherwise (({nil})).
--- IO#pid
    returns (({pid})) if (({popen}))ed, otherwise raises exception.


--- dist/io.c	Wed May 17 09:09:40 2000
+++ build/io.c	Wed May 17 09:34:24 2000
@@ -393,6 +393,29 @@
 }
 
 static VALUE
+rb_io_pipe_p(io)
+    VALUE io;
+{
+    OpenFile *fptr;
+
+    GetOpenFile(io, fptr);
+    if (!fptr->pid)
+	return Qnil;
+    return INT2FIX(fptr->pid);
+}
+
+static VALUE
+rb_io_pid(io)
+    VALUE io;
+{
+    VALUE pid = rb_io_pipe_p(io);
+
+    if (NIL_P(pid))
+	rb_raise(rb_eTypeError, "no process");
+    return pid;
+}
+
+static VALUE
 rb_io_to_io(io)
     VALUE io;
 {
@@ -3337,6 +3360,8 @@
 
     rb_define_method(rb_cIO, "ioctl", rb_io_ioctl, -1);
     rb_define_method(rb_cIO, "fcntl", rb_io_fcntl, -1);
+    rb_define_method(rb_cIO, "pipe?", rb_io_pipe_p, 0);
+    rb_define_method(rb_cIO, "pid", rb_io_pid, 0);
 
     rb_stdin = orig_stdin = prep_stdio(stdin, FMODE_READABLE, rb_cIO);
     rb_define_hooked_variable("$stdin", &rb_stdin, 0, set_stdin);

-- 
そうだ 強気に ちょっと インチキに☆彡
    中田 "Bugるくらいがちょうどいいかも;-)" 伸悦

In This Thread