|
> こちらの実行環境は Solaris8 です。
Solaris は得意ではありませんが、pty(擬似端末 pseudo terminal)の実装に
STREAMS を使っているかもしれないので、forkpty() がないとすれば、
次のようなコードが必要かもしれません。
このコードはエラーチェックをしていないし、たぶん動かないと思います。
int main(void)
{
char *pn, buf[1024]; int fd, slave, n;
fd = open("/dev/ptmx", O_RDWR);
grantpt(fd);
unlockpt(fd);
pn = ptsname(fd);
n = fork();
if (n == 0) { /* child process */
slave = open(pn, O_RDWR, 0);
ioctl(slave, I_PUSH, "ptem");
ioctl(slave, I_PUSH, "ldterm");
close(fd);
dup2(slave, 0); dup2(slave, 1); dup2(slave, 2);
ioctl(slave, TIOCSCTTY, 0);
system("prob_a");
return 0;
}
/* parent process */
n = read(fd, buf, 1024);
if (strncmp(buf, "password?", 9) == 0)
write(fd, "himitsu\n", 8);
wait(0);
return 0;
}
|