[ruby-talk:00340] Re: Help :syscall

From: matz@... (Yukihiro Matsumoto)
Date: 1999-05-25 07:52:10 UTC
List: ruby-talk #340
Hi.

In message "[ruby-talk:00339] Help :syscall"
    on 99/05/25, Pros Yeboah <yeboah@tu-harburg.de> writes:

|My syscall can only dump cores or produce 0 results.
|But  that of  the extended module ,Perl produce correct results.

This is a bug.  I was assuming system calls always return zeros on
success.  Of course, this is not true.  getpid(=20) is the example.

Here's the patch.  I already commited this change to the Anon CVS at
cvs.netlab.co.jp.

--- io.c	1999/05/18 06:06:12	1.1.1.3.2.16
+++ io.c	1999/05/25 07:28:11
@@ -2641,6 +2639,6 @@
     }
     TRAP_END;
-    if (retval == -1) rb_sys_fail(0);
-    return INT2FIX(0);
+    if (retval < 0) rb_sys_fail(0);
+    return INT2NUM(retval);
 #else
     rb_notimplement();

In This Thread

Prev Next