Mkfifo in Ruby 1.8?

Why is (the library call) mkfifo missing in Ruby 1.8? Is there a way
to do it simply (without coding the trivial C stub) in Ruby, other
than system(“mkfifo #{path}”)

···


Basile STARYNKEVITCH http://starynkevitch.net/Basile/
email: basilestarynkevitchnet
aliases: basiletunesorg = bstarynknerimnet
8, rue de la Faïencerie, 92340 Bourg La Reine, France

In article slrnc26ead.s49.basile-news@hector.lesours,

Why is (the library call) mkfifo missing in Ruby 1.8? Is there a way
to do it simply (without coding the trivial C stub) in Ruby, other
than system(“mkfifo #{path}”)

You could use syscall :slight_smile: No I’m not advocating this seriously.

Linux 2.4

SYS_mknod = 14
S_IFIFO = 4096
name = ‘my_fifo’

puts “result is #{syscall(SYS_mknod, name, 0666 | S_IFIFO)}”

Mike

···

Basile Starynkevitch [news] basile-news@starynkevitch.net wrote:

mike@stok.co.uk | The “`Stok’ disclaimers” apply.
http://www.stok.co.uk/~mike/ | GPG PGP Key 1024D/059913DA
mike@exegenix.com | Fingerprint 0570 71CD 6790 7C28 3D60
http://www.exegenix.com/ | 75D2 9EC4 C1C0 0599 13DA

Hi,

At Fri, 6 Feb 2004 16:45:01 +0900,
Basile Starynkevitch [news] wrote in [ruby-talk:91680]:

Why is (the library call) mkfifo missing in Ruby 1.8? Is there a way
to do it simply (without coding the trivial C stub) in Ruby, other
than system(“mkfifo #{path}”)

Because just nobody has wanted it yet, perhaps.

Index: configure.in

···

===================================================================
RCS file: /cvs/ruby/src/ruby/configure.in,v
retrieving revision 1.223
diff -u -2 -p -d -r1.223 configure.in
— configure.in 30 Jan 2004 17:39:04 -0000 1.223
+++ configure.in 7 Feb 2004 02:17:56 -0000
@@ -397,5 +397,5 @@ AC_CHECK_FUNCS(fmod killpg wait4 waitpid
getpriority getrlimit dlopen sigprocmask sigaction _setjmp
setsid telldir seekdir fchmod mktime timegm cosh sinh tanh\

  •     setuid setgid)
    
  •     setuid setgid mkfifo mknod)
    

AC_ARG_ENABLE(setreuid,
[ --enable-setreuid use setreuid()/setregid() according to need even if obsolete.],
Index: file.c

RCS file: /cvs/ruby/src/ruby/file.c,v
retrieving revision 1.178
diff -u -2 -p -d -r1.178 file.c
— file.c 4 Feb 2004 13:39:49 -0000 1.178
+++ file.c 7 Feb 2004 03:07:22 -0000
@@ -3207,4 +3207,101 @@ rb_f_test(argc, argv)
}

+/*

    • call-seq:
    • File.mknod(file_name, [type, [mode, [dev]]])  => 0
      
    • Create a filesystem node (file, device special file or named pipe)
    • named file_name, specified by mode and dev.
    • type and mode specifies the type and the permissions of node to
    • be created respectively.
    • The permissions are modified by the process’s umask in the usual
    • way: the permissions of the created node are (mode & ~umask).
    • type should be one of +?f+, +?c+, +?b+ and +?p+ to specify a
    • normal file (which will be created empty), character special file,
    • block special file or FIFO (named pipe), respectively, or +nil+,
    • which will create a normal file.
  • */

+static VALUE
+rb_file_s_mknod(argc, argv)

  • int argc;
  • VALUE *argv;
    +{
    +#ifdef HAVE_MKNOD
  • VALUE path, type, vmode, vdev;
  • int mode = 0666, dev = 0, t;
  • rb_secure(4);
  • switch (rb_scan_args(argc, argv, “13”, &path, &type, &vmode, &vdev)) {
  •  case 4:
    
  • dev = NUM2INT(vdev);
  •  case 3:
    
  • mode = NUM2INT(vmode) & ~S_IFMT;
  • }
  • SafeStringValue(path);
  • if (!NIL_P(type)) {
  • rb_check_safe_obj(type);
  • switch (t = NUM2CHR(type)) {
  • case 'f': mode |= S_IFREG; break;
    
  • case 'c': mode |= S_IFCHR; break;
    

+#ifdef S_IFBLK

  • case 'b': mode |= S_IFBLK; break;
    

+#endif
+#ifdef S_IFIFO

  • case 'p': mode |= S_IFIFO; break;
    

+#endif

  • default:
    
  •   rb_raise(rb_eArgError, "unknown node type - %c", t);
    
  • }
  • }
  • if (mknod(RSTRING(path)->ptr, mode, dev)) {
  • rb_sys_fail(0);
  • }
    +#else
  • rb_notimplement();
    +#endif
  • return INT2FIX(0);
    +}

+/*

    • call-seq:
    • File.mkfifo(file_name, mode)  => 0
      
    • Creates a FIFO special file with name file_name. mode
    • specifies the FIFO’s permissions. It is modified by the process’s
    • umask in the usual way: the permissions of the created file are
    • (mode & ~umask).
  • */

+static VALUE
+rb_file_s_mkfifo(argc, argv)

  • int argc;
  • VALUE *argv;
    +{
    +#if !defined HAVE_MKFIFO && defined HAVE_MKNOD && defined S_IFIFO
    +#define mkfifo(path, mode) mknod(path, (mode)&~S_IFMT|S_IFIFO, 0)
    +#define HAVE_MKFIFO
    +#endif
    +#ifdef HAVE_MKFIFO
  • VALUE path, vmode;
  • int mode = 0666;
  • rb_secure(4);
  • if (rb_scan_args(argc, argv, “11”, &path, &vmode) > 1) {
  • mode = NUM2INT(vmode);
  • }
  • SafeStringValue(path);
  • if (mkfifo(RSTRING(path)->ptr, mode)) {
  • rb_sys_fail(0);
  • }
    +#else
  • rb_notimplement();
    +#endif
  • return INT2FIX(0);
    +}

@@ -4209,4 +4306,6 @@ Init_File()
rb_define_singleton_method(rb_cFile, “umask”, rb_file_s_umask, -1);
rb_define_singleton_method(rb_cFile, “truncate”, rb_file_s_truncate, 2);

  • rb_define_singleton_method(rb_cFile, “mknod”, rb_file_s_mknod, -1);
  • rb_define_singleton_method(rb_cFile, “mkfifo”, rb_file_s_mkfifo, -1);
    rb_define_singleton_method(rb_cFile, “expand_path”, rb_file_s_expand_path, -1);
    rb_define_singleton_method(rb_cFile, “basename”, rb_file_s_basename, -1);


Nobu Nakada

I just installed ruby-1.8.1 and found this problem.

make test – worked fine during the installation of ruby

···

The program below will work on the same machine using ruby-1.6.8

What can I do to smoke this bug out?

Bob Gustafson


bash-2.03# ruby bugtest.rb
/usr/local/lib/ruby/1.8/sparc-solaris2.7/pty.so: [BUG] Segmentation fault
ruby 1.8.1 (2003-12-25) [sparc-solaris2.7]

Abort (core dumped)

bash-2.03# cat bugtest.rb
require 'pty’
puts "This is a test"
bash-2.03#

Hi,

···

In message “pty.so: [BUG] Segmentation fault” on 04/02/07, Bob Gustafson bobgus@rcn.com writes:

The program below will work on the same machine using ruby-1.6.8
What can I do to smoke this bug out?

Hmm, is there somebody to confirm this on Solaris 2.7?

						matz.

Yukihiro Matsumoto wrote:

Hi,

The program below will work on the same machine using ruby-1.6.8
What can I do to smoke this bug out?

Hmm, is there somebody to confirm this on Solaris 2.7?

  					matz.

No segfault here.

$ ruby -v bugtest.rb
ruby 1.8.1 (2003-12-25) [sparc-solaris2.7]
This is a test
$ cat bugtest.rb
require ‘pty’
puts “This is a test”

However, I did have some strange behavior while updating from 2003-12-22
to 2003-12-25. After building and installing the latter, ruby -v told me
I still had the earlier version. So I blew away my entire
$PREFIX/lib/ruby, and rebuilt, and that fixed the version discrepancy.

Is it possible that the include path found version.h in
$PREFIX/lib/ruby/1.8/sparc-solaris2.7/ before the one in the build dir?
I’ve never seen this problem on linux, and I don’t recall seeing it
before on solaris.

A typical compiler invocation looks like:

gcc -I/usr/path/include -I. -I. -I/usr/path/include -c class.c

So it does look like my install dir is being searched first. My
configure command is simply

./configure --prefix=/usr/path

Anyway, the OP might want to try manually deleting lib/ruby and rebuilding.

···

In message “pty.so: [BUG] Segmentation fault” > on 04/02/07, Bob Gustafson bobgus@rcn.com writes:

Hi,

At Sun, 8 Feb 2004 07:11:47 +0900,
Joel VanderWerf wrote in [ruby-talk:91760]:

Is it possible that the include path found version.h in
$PREFIX/lib/ruby/1.8/sparc-solaris2.7/ before the one in the build dir?
I’ve never seen this problem on linux, and I don’t recall seeing it
before on solaris.

No.

A typical compiler invocation looks like:

gcc -I/usr/path/include -I. -I. -I/usr/path/include -c class.c

It is strange. Don’t you set CFLAGS env? Otherwise, ‘-g -O2’
should appear instead.

···


Nobu Nakada

Oops. That’s exactly what it was. I have:

declare -x CFLAGS=“-I/usr/path/include”

That was for some other software. Good to know that can interfere with
ruby builds. Thanks.

···

nobu.nokada@softhome.net wrote:

Hi,

At Sun, 8 Feb 2004 07:11:47 +0900,
Joel VanderWerf wrote in [ruby-talk:91760]:

Is it possible that the include path found version.h in
$PREFIX/lib/ruby/1.8/sparc-solaris2.7/ before the one in the build dir?
I’ve never seen this problem on linux, and I don’t recall seeing it
before on solaris.

No.

A typical compiler invocation looks like:

gcc -I/usr/path/include -I. -I. -I/usr/path/include -c class.c

It is strange. Don’t you set CFLAGS env? Otherwise, ‘-g -O2’
should appear instead.

As suggested in an earlier email, I blew away /usr/local/lib/ruby - which
took care of the subdirectories 1.6, 1.8, and site_ruby.

I also deleted libruby-static.a which was in /usr/local/lib. (This file was
regenerated during the rebuild process below - a bit odd?)

Then I untarred the distribution file, did:

./configure 2>&1 | tee config.out
make 2>&1 | tee make.out
make test 2>&1 | tee test.out
make install 2?&1 | tee install.out

ruby testbug.rb

I got exactly the same result as before:

bash-2.03# ruby bugtest.rb
/usr/local/lib/ruby/1.8/sparc-solaris2.7/pty.so: [BUG] Segmentation fault
ruby 1.8.1 (2003-12-25) [sparc-solaris2.7]

Abort (core dumped)
bash-2.03#
bash-2.03# cat bugtest.rb
require ‘pty’
puts “This is a test”
bash-2.03#

If you are interested in looking at the output of the build phases (*.out),
I put tham up on http://66.175.1.68/rubybug.html

Thanks for any help.

Bob Gustafson

Joel VanderWerf wrote in [ruby-talk: 91779]

···

nobu.nokada@softhome.net wrote:

Hi,

At Sun, 8 Feb 2004 07:11:47 +0900,
Joel VanderWerf wrote in [ruby-talk:91760]:

Is it possible that the include path found version.h in
$PREFIX/lib/ruby/1.8/sparc-solaris2.7/ before the one in the build dir?
I’ve never seen this problem on linux, and I don’t recall seeing it
before on solaris.

No.

A typical compiler invocation looks like:

gcc -I/usr/path/include -I. -I. -I/usr/path/include -c class.c

It is strange. Don’t you set CFLAGS env? Otherwise, ‘-g -O2’
should appear instead.

Oops. That’s exactly what it was. I have:

declare -x CFLAGS=“-I/usr/path/include”

That was for some other software. Good to know that can interfere with
ruby builds. Thanks.

If you are interested in looking at the output of the build phases (*.out),
I put tham up on http://66.175.1.68/rubybug.html

This is the problem

checking whether the linker is GNU ld… yes

It work fine with

moulon% gcc -v
Reading specs from /opt/gcc/lib/gcc-lib/sparc-sun-solaris2.7/3.3.2/specs
Configured with: …/gcc-3.3.2/configure --prefix=/opt/gcc --with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --disable-nls
Thread model: posix
gcc version 3.3.2
moulon%

See --with-as and --with-ld

···

Guy Decoux

Hmm, perhaps I am working with a collection of old cats and dogs - gcc
2.95.2 and Sun linker.

The ‘make test’ in the Ruby build suite is a bit optimistic maybe?

date

Mon Feb 9 09:55:45 CST 2004

gcc -v

Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
gcc version 2.95.2 19991024 (release)

···

ld -V

ld: Software Generation Utilities - Solaris Link Editors: 5.7-1.280

as -V

GNU assembler version 2.13 (sparc-sun-solaris2.7) using BFD version 2.13

BobG

written by ts decoux@moulon.inra.fr on 09 Feb 2004 11:11:54 +0100

If you are interested in looking at the output of the build phases (*.out),
I put tham up on http://66.175.1.68/rubybug.html

This is the problem

checking whether the linker is GNU ld… yes

It work fine with

moulon% gcc -v
Reading specs from /opt/gcc/lib/gcc-lib/sparc-sun-solaris2.7/3.3.2/specs
Configured with: …/gcc-3.3.2/configure --prefix=/opt/gcc
–with-as=/usr/ccs/bin/as --with-ld=/usr/ccs/bin/ld --disable-nls
Thread model: posix
gcc version 3.3.2
moulon%

See --with-as and --with-ld

Guy Decoux

# gcc -v
Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
gcc version 2.95.2 19991024 (release)
#

Well, you have an old compiler, but the problem is here

# ld -V
ld: Software Generation Utilities - Solaris Link Editors: 5.7-1.280

The linker for gcc is configured *at compile time* (when you compile gcc)
and not at runtime and apparently your gcc was compiled with the GNU ld
and not the Solaris ld

try this to see which ld is called

    touch /tmp/a.c
    gcc -v /tmp/a.c

Guy Decoux

Hmm, lots of stuff

date

Mon Feb 9 15:51:40 CST 2004

touch /tmp/a.c

gcc -v /tmp/a.c

Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
gcc version 2.95.2 19991024 (release)
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/cpp -lang-c -v -D__GNUC__=2
-D__GNUC_MINOR__=95 -Dsparc -Dsun -Dunix -D__svr4__ -D__SVR4 -D__sparc__
-D__sun
__ -D__unix__ -D__svr4__ -D__SVR4 -D__sparc -D__sun -D__unix -Asystem(unix)
-Asy
stem(svr4) -D__GCC_NEW_VARARGS__ -Acpu(sparc) -Amachine(sparc) /tmp/a.c
/var/tmp
/ccgVUTGM.i
GNU CPP version 2.95.2 19991024 (release) (sparc)
#include “…” search starts here:
#include <…> search starts here:
/usr/local/include
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/…/…/…/…/sparc-sun-solari
s2.7/include
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/include
/usr/include
End of search list.
The following default directories have been omitted from the search path:
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/…/…/…/…/include/g+±3
End of omitted list.
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/cc1 /var/tmp/ccgVUTGM.i
-qui
et -dumpbase a.c -version -o /var/tmp/ccYD6mJs.s
GNU C version 2.95.2 19991024 (release) (sparc-sun-solaris2.7) compiled by
GNU C
version 2.95.2 19991024 (release).
/usr/local/sparc-sun-solaris2.7/bin/as -V -Qy -s -o /var/tmp/cc6FNEaa.o
/var/tm
p/ccYD6mJs.s
GNU assembler version 2.13 (sparc-sun-solaris2.7) using BFD version 2.13
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/collect2 -V -Y
P,/usr/ccs/li
b:/usr/lib -Qy /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/crt1.o
/usr/lo
cal/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/crti.o /usr/ccs/lib/values-Xa.o
/usr
/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/crtbegin.o
-L/usr/local/lib/gcc-l
ib/sparc-sun-solaris2.7/2.95.2 -L/usr/local/sparc-sun-solaris2.7/lib
-L/usr/ccs/
bin -L/usr/ccs/lib -L/usr/local/lib /var/tmp/cc6FNEaa.o -lgcc -lc -lgcc
/usr/loc
al/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/crtend.o
/usr/local/lib/gcc-lib/sparc
-sun-solaris2.7/2.95.2/crtn.o
/usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/crt1.o: In function
_start': /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/crt1.o(.text+0x5c): undefined reference to main’
GNU ld version 2.13
Supported emulations:
elf32_sparc
elf64_sparc
collect2: ld returned 1 exit status

···

Guy Decoux wrote in rubytalk [92487]

gcc -v

Reading specs from /usr/local/lib/gcc-lib/sparc-sun-solaris2.7/2.95.2/specs
gcc version 2.95.2 19991024 (release)

Well, you have an old compiler, but the problem is here

ld -V

ld: Software Generation Utilities - Solaris Link Editors: 5.7-1.280

The linker for gcc is configured at compile time (when you compile gcc)
and not at runtime and apparently your gcc was compiled with the GNU ld
and not the Solaris ld

try this to see which ld is called

touch /tmp/a.c
gcc -v /tmp/a.c

Guy Decoux

Like I've said previously this is the problem

GNU assembler version 2.13 (sparc-sun-solaris2.7) using BFD version 2.13
GNU ld version 2.13

use a gcc compiled with /usr/ccs/bin/as and /usr/ccs/bin/ld

You have pre-compiled version on http://sunfreeware.com/

Guy Decoux

ts decoux@moulon.inra.fr wrote in message news:200402100948.i1A9mWx03395@moulon.inra.fr

Like I’ve said previously this is the problem

GNU assembler version 2.13 (sparc-sun-solaris2.7) using BFD version 2.13
GNU ld version 2.13

use a gcc compiled with /usr/ccs/bin/as and /usr/ccs/bin/ld

You have pre-compiled version on http://sunfreeware.com/

Guy Decoux

I’ve noticed that in general, upgrading to gcc 3.3.2 on Solaris has
solved a lot of problems.

Regards,

Dan

Hi, I reresend this message.

Hi Alex,

Just some ideas for the web page to get you started.
Let’s go with a “mission statement” (ack!) and some
bio information (including your own). Park and
Shashank, if you’re willing please send some bio
information to Alex as well for the web page. :slight_smile:

Dan

Project Goals

The goal of this project is to make Ruby an excellent
choice for developing on the Win32 platform. Ruby has
lagged behind Perl and, especially, Python in the
Win32 arena. We intend to not only equal Perl and
Python in terms of Win32 development viability, but
surpass them both in terms of a superior API and
additional packages.

Bio: Daniel J. Berger (Project Leader)

Originally a student of Classical History, Daniel
Berger became a computer programmer when he joined the
US Air Force in late 1995 where he learned ADA, C and
Perl. After getting out of the military in 1999, he
eventually found a job working for US West (now Qwest)
as a Perl/Tk programmer. He eventally discovered Ruby
in 2001 or so, and has been enamored ever since.

These days Daniel spends most of his time developing
production support applications using Ruby, along with
a healthy dose of Oracle database interaction.

Daniel has numerous packages on the RAA as well as a
few Perl modules on CPAN.

I will intruduce myself.

I was born before one year of the Apollo 11 missoin.

I started computer programming in 1983 with BASIC on 8bit machine.

I have become interested in languages both human and computer languages.

I specialized in physics at the university in 1987.

I have studied several human languages like English, French, German,
Spanish, Russian, Japanese, Chinese and Latin in my college days.

But I cannot speak fluently any of them :slight_smile:

Besides, I also have studied several programming languages like Assembly,
Pascal, C, C++, BASIC, Prolog, FORTRAN, COBOL, Ada, Modula, Smalltalk etc
during my college life.

I found a job at a small company called HANGANG Systems after graduation.

Since then going through some companies I learned by experience various
environments: Windows, Linux, SUN, HP, DEC, Oracle, Informix, SQL, Motif,
Apache, PHP, ASP, Java etc.

I took part in Korean broadcasting satellite control system coworked with
ETRI and a company Teltek located at Vancouver,Canada in 1995.

I developed the Ozone Monitoring and Alarming System for Korean Ministry of
Environment in 1998.

I met Ruby accidentally at computer magazine in 2000.

I made some solutions with Ruby in company such as real-time meta search
engine, doname name whois query, calendar system conversion, web auto
scripting.

I contribued for Ruby community with a little extension libraries like
wxRuby, PCRE, win32-popen etc.

Now I’m working at a small company called INDI Systems, Inc.
(http://www.indi-tech.com/default.asp)

Edit for your purpose. :slight_smile:

Regards,

Park Heesob

Project Goals

The goal of this project is to make Ruby an excellent
choice for developing on the Win32 platform. Ruby has
lagged behind Perl and, especially, Python in the
Win32 arena. We intend to not only equal Perl and
Python in terms of Win32 development viability, but
surpass them both in terms of a superior API and
additional packages.

After the release of the “superior API”/additional packages,
People will compile them into parrot VM,
then both Perl and Python can call those library as if
the library were written in their languages.

Ruby can do the samething vis versa.

Why reinvent the wheel …

“romerun” romerun@romerun.com wrote in message news:001601c3f14f$734380e0$95730197@wrongturn

Project Goals

The goal of this project is to make Ruby an excellent
choice for developing on the Win32 platform. Ruby has
lagged behind Perl and, especially, Python in the
Win32 arena. We intend to not only equal Perl and
Python in terms of Win32 development viability, but
surpass them both in terms of a superior API and
additional packages.

Well, first let me say that this post was made accidentally by Park to
this newsgroup. It was meant as a private email for our web guy.

After the release of the “superior API”/additional packages,
People will compile them into parrot VM,
then both Perl and Python can call those library as if
the library were written in their languages.

Ruby can do the samething vis versa.

Why reinvent the wheel …

Possible answers:

  1. Because I don’t feel like waiting 2-3 years for Parrot to be
    finished.
  2. Because in some cases the Win32 API calls the Python and
    (especially) Perl libraries use are deprecated.
  3. Because in some cases the Perl and Python libraries don’t support
    everything we currently, or plan to, support, e.g. asynchronous named
    pipes (now in CVS btw).
  4. Because I can.

Regards,

Daniel Berger
Win32 Utils Project Lead