From: SHIROYAMA Takayuki Date: 1999-06-25T19:53:38+09:00 Subject: [ruby-list:15112] pty on NeXTSTEP3.3J しろやまです。 以前申してました、ptyがNeXTSTEP環境にてコンパイルでき ない件に関してです。 問題点としては、まずNeXTでは wait3が int wait3(union wait *, int, struct rusage *); と定義、また #define WIFSTOPPED(x) ((x).w_stopval == WSTOPPED) (また、w_stopvalは実際には w_S.w_stopvalというメンバになる) と定義されております。 ところが、pty.c では int statusp; っと定義された変数 statuspを使って cpid = wait3((int *) &statusp, WUNTRACED|WNOHANG, 0); っと wait3へ(さらに (int *)でキャストされて(T^T))渡され、 また183行目で if (WIFSTOPPED(statusp)) { /* suspend */ っと使われており、これが if( statusp.w_S.w_stopval == WSTOPPED ) っと展開され、 int型には w_Sなんてメンバが無くて、 pty.c:183: request for member `w_S' in something not a structure or union っとエラーになってしまう訳です。(もちろん、wait3の引数など でも型が違うので warningが出ますが) 以下のパッチで、NeXTの場合に限り、statuspの型を union wait に変更しており、これにより上記の問題を回避すると、コンパイ ルには成功しました。 *** pty.orig/pty.c Thu Jun 10 19:31:52 1999 --- pty/pty.c Fri Jun 25 12:22:02 1999 *************** *** 154,160 **** --- 154,164 ---- { int cpid; int i,n = -1; + #ifndef NeXT int statusp; + #else + union wait statusp; + #endif for (;;) { #ifdef HAVE_WAITPID ところが、これだけでは以下のようなエラーが出て何故かうまく いきません(^^; tiger> ruby ./shl.rb ./shl.rb:12: [BUG] Segmentation fault なのでGDBでおっかけてみました。 tiger> gdb ../../ruby GDB is free software and you are welcome to distribute copies of it under certain conditions; type "show copying" to see the conditions. There is absolutely no warranty for GDB; type "show warranty" for details. GDB 4.7 (NeXT 3.1), Copyright 1992 Free Software Foundation, Inc... Reading symbols from /Users/psi/work/ruby/ruby-1.3.4-990624/ext/pty/../../ruby...done. Reading symbols from /usr/shlib/libsys_s.B.shlib...done. (gdb) run shl.rb Starting program: /Users/psi/work/ruby/ruby-1.3.4-990624/ext/pty/../../ruby shl.rb Reading symbols from loaded file...done. Program generated(1): Memory access exception on address 0xbf006570 (invalid address). Reading in symbols for eval.c...done. require_method (argc=2, argv=0xbffff6a8, self=2072272) at eval.c:4781 4781 rb_f_require(self, argv[i]); (gdb) where Reading in symbols for main.c...done. Reading in symbols for crt0.c...done. #0 require_method (argc=2, argv=0xbffff6a8, self=2072272) at eval.c:4781 #1 0xbb01 in call_cfunc (func=0xe19c , recv=2072272, len=0, argc=1, argv=0x2) at eval.c:3663 #2 0xc05e in rb_call0 (klass=2075792, recv=2072272, id=7721, argc=1, argv=0xbffff6a8, body=0x1ef854, nosuper=1) at eval.c:3802 #3 0xc7fd in rb_call (klass=2075792, recv=2072272, mid=7721, argc=1, argv=0xbffff6a8, scope=1) at eval.c:3996 #4 0x8004 in rb_eval (self=2072272, node=0x1ee9b8) at eval.c:2192 #5 0x6984 in rb_eval (self=2072272, node=0x1ee92c) at eval.c:1729 #6 0x51d4 in eval_node (self=2072272) at eval.c:967 #7 0x52c2 in ruby_run () at eval.c:1003 #8 0x3f5c in main (argc=2, argv=0xbffffc74, envp=0xbffffc80) at main.c:39 #9 0x3eff in start () at crt0.c:134 (gdb) list 4776 VALUE self; 4777 { 4778 int i; 4779 4780 for (i=0; i