Thursday Apr 30, 2009

Tip: Different master pty regards between Solaris and Linux

转载时请以超链接形式标明文章原始出处和作者信息
http://blogs.sun.com/weixue/entry/tip_differece_master_pty_regards

During investigation Opensolaris bug 6824625. The root cause is the different result of calling tcsetattr() for pty on Solaris and Linux.
Solaris and Linux treat slave pty differently.
For opening pty (Pseudo Terminal), there have two steps, open master device and slave device sequently. On Solaris, master pty device is not regarded as a terminal device. it regard slave device as a terminal device only.
But On Linux(I tested on Ubuntu), both master and slave devices are regarded as terminal devices.

So, tcsetattr() can work for both master and slave device on Linux. But, tcsetattr() can only work for slave pty device on Solaris. You can also use isatty() to tests if file descriptor is associated with terminal device .

It's a useful tip for porting terminal application between Solaris and Linux.

A piece of code for your reference, how to open pty: You can see that ioctl() only apply to slave device on Solaris(in macro #ifdef __sun).

FYI.

The Open Group Base Specifications : General Terminal Interface.
Concept of pty, tty..(in Chinese)

About

williamxue

Search

Archives
« April 2014
SunMonTueWedThuFriSat
  
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
   
       
Today