From: Yui NARUSE Date: 2010-08-14T19:55:45+09:00 Subject: [ruby-dev:42034] [Bug #3673] PTY.getpty with IO.pipe doesn't finish on FreeBSD チケット #3673 が更新されました。 (by Yui NARUSE) まずはテストの修正ありがとうございます。 確かに以下の通り close(2) の前にエコーによって出力された文字列を読んであげるとちゃんと閉じられますね。 うーん、前の Bug #3515 と関係あるのかなぁ。 #include #include #include #include #include #include #include int main(int argc, char *argv[]) { int m, s; char *slavedev; struct termios t; if ((m = posix_openpt(O_RDWR|O_NOCTTY)) == -1) { perror("posix_openpt"); exit(1); } if (grantpt(m) == -1) { perror("grantpt"); exit(1); } if (unlockpt(m) == -1) { perror("unlockpt"); exit(1); } if ((slavedev = ptsname(m)) == NULL) { perror("ptsname"); exit(1); } if ((s = open(slavedev, O_RDWR|O_NOCTTY, 0)) == -1) { perror("open(slavedev)"); exit(1); } if (tcgetattr(s, &t) == -1) { perror("tcgetattr"); } t.c_lflag &= ~(tcflag_t)(ECHO|ECHOE|ECHOK|ECHONL); //if (tcsetattr(s, TCSANOW, &t) == -1) { perror("tcsetattr"); } if (write(m, "a", 1) == -1) { perror("write"); exit(1); } { char buf[100]; if (read(m, buf, 1) == -1) { perror("write"); exit(1); } printf("echo: %c\n", buf[0]); } if (close(s) == -1) { perror("close"); exit(1); } return 0; } ---------------------------------------- http://redmine.ruby-lang.org/issues/show/3673 ---------------------------------------- http://redmine.ruby-lang.org