[#5219] ruby for perl users — Noritsugu Nakamura <nnakamur@...>

35 messages 1997/11/09
[#5220] Re: ruby for perl users — tateishi@... (Tateishi Takaaki) 1997/11/09

立石です。

[#5224] Re: ruby for perl users — shugo@... (Shugo Maeda) 1997/11/09

前田です。

[#5243] read from subprocess — Kikutani Makoto <kikutani@...>

きくたにです。

17 messages 1997/11/10
[#5250] Re: read from subprocess — matz@... (Yukihiro Matsumoto) 1997/11/11

まつもと ゆきひろです

[#5300] Win32用の Rubyでの tkの使用 — Tomoaki Takebayashi <tota@...>

はじめまして、竹林といいます。

14 messages 1997/11/15
[#5302] Re: Win32用の Rubyでの tkの使用 — WATANABE Hirofumi <eban@...> 1997/11/15

わたなべです.

[#5303] Re: Win32 用の Rubyでの tkの使用 — Tomoaki Takebayashi <tota@...> 1997/11/15

[#5305] Re: Win32 用の Ruby での tk の使用 — aito@...5sun.yz.yamagata-u.ac.jp 1997/11/17

あ伊藤です.

[#5320] ruby 1.0-971118 released — matz@... (Yukihiro Matsumoto)

まつもと ゆきひろです

20 messages 1997/11/18
[#5337] Re: ruby 1.0-971118 released — WATANABE Hirofumi <watanabe@...> 1997/11/19

わたなべです.

[#5340] Re: ruby 1.0-971118 released — matz@... (Yukihiro Matsumoto) 1997/11/19

まつもと ゆきひろです

[#5398] 配列への追加について — a-nisida@... (西田明良)

はじめまして、西田@初心者 と申します。m(..)m

16 messages 1997/11/22

[ruby-list:5243] read from subprocess

From: Kikutani Makoto <kikutani@...>
Date: 1997-11-10 15:09:12 UTC
List: ruby-list #5243
きくたにです。

前にもちょっと書いたことがありますが、添付1のC programを
走らせて、子プロセスの添付2のrubyスクリプトが文字列"ruby"を
受け取らないのはなぜでしょう?

似たようなことをPythonでやると添付の3番目で動くのですけど。

-- 
人生を背負い投げ

菊谷 誠(Kikutani Makoto)  kikutani@eis.or.jp hgf03701@niftyserve.or.jp
                          http://www.eis.or.jp/muse/kikutani/

Attachments (2)

ipc-test0.c (1.36 KB, text/x-csrc)
#include <stdio.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <stdlib.h>

main()
{
   int pid, i, slen, l;
   char *cmd, *arg0, arg1[8], *str;
   int channel[2]; /* IPC channel with child process */
   char buf[10];

   if (socketpair(AF_UNIX, SOCK_STREAM, 0, channel) < 0) {
      fprintf(stderr, "socketpair failed\n");
      return;
   }

   if ((pid = vfork()) == -1) {
      return;
   }

   if (pid == 0) {		/* child process */
#if 0
      cmd = "./ipc0";
      arg0 = "ipc0";
#else
      cmd = "./ipc0.rb";
      arg0 = "ipc0.rb";
#endif
      sprintf(arg1, "%d", channel[0]);
      execl(cmd, arg0, arg1, NULL);
      perror("execl failed");
      close( channel[0] );
      _exit( 1 );
   }

   /* parent process */	
   close(channel[0]);


   i = 0x12345678;
   if ((l = write( channel[1], &i, sizeof(int))) != sizeof(int))
     printf("ipc-test0.c: int write failed. written length =  %d\n", l);

   if ((l = read( channel[1], buf, 2)) != 2)
     printf("ipc-test0.c: int read failed. read length =  %d\n", l);
   printf("buf = %s\n", buf);

   str = "ruby";
   slen = strlen(str);
   fflush(stdout);
   if ((l = write( channel[1], str, slen)) != slen)
     printf("ipc-test0.c: str write failed. written length =  %d\n", l);
   if ((l = read( channel[1], buf, 2)) != 2)
     printf("ipc-test0.c: int read failed. read length =  %d\n", l);
   printf("buf = %s\n", buf);

}
ipc0.py (443 Bytes, application/x-sh)

In This Thread

Prev Next