2011-09-20 121 views
2

我嘗試通過linux os上的一對僞tty來打開網絡連接。在僞tty上運行slattach

# slattach -v /dev/ptmx 
cslip started on /dev/ptmx interface sl0 

好的,這是僞tty的「創建方」。

我可以看看/ dev/pts並在那裏找到新的pty。 如果我現在嘗試也使用slattach時在這方面我有:

slattach -v /dev/pts/3 
slattach: tty_open(/dev/pts/3, RW): Input/output error 

我跟蹤與strace的:

28 5505 write(1, "slattach: tty_open: trying to op"..., 46) = 46 
29 5505 open("/dev/pts/3", O_RDWR|O_NONBLOCK) = -1 EIO (Input/output error) 
30 5505 write(2, "slattach: tty_open(/dev/pts/3, R"..., 55) = 55 
31 5505 exit_group(3) 

所有這一切都發生在Ubuntu上的不同的發行版,在10.04和11.04,兩者測試正在失敗。

我在做什麼錯了?

回答

1

您可能需要查看手冊頁pty(7)

基本上,/ dev/ptmx使用Unix 98僞終端接口,並要求您的程序使用grantpt(3)和unlockpt(3)。在這裏,slattach(打開/ dev/ptmx,而不是另一個)不會這樣做,並且任何試圖打開與主設備關聯的從設備僞終端的程序都會失敗,就像您遇到的那樣。

您可以強制slattach時通過重載的open()與外部 例程中調用做grantpt()和unlockpt(),see this example

相關問題