views:

224

answers:

1

i am the owner of the pty device created like this permissions are crw-w----

mknod pty1 c 1 1
cat > pty1

tells me operation not permitted.

what i want to do later is that i open the file from a program using open and call write to send output to the terminal, as if it is a disk file.

why is cat not working. can we write to a pty or read from a pty using open and write.

can we do this from java. java writes to a file that is actually a pty.

source of problem: http://stackoverflow.com/questions/2055918/forcing-a-program-to-flush-its-standard-output-when-redirected/

Update: is the question not clear. do i need to add more info?

output of ls -la

crw--w---- 1 iamrohitbanga users 1, 1 2010-01-13 18:27 pty1
crw--w---- 1 iamrohitbanga users 1, 2 2010-01-13 18:29 pty2

also

when i do cat /dev/pts/0 in one terminal and cat > /dev/pts/0 in another, i do not see the input of one getting transferred to another.

+3  A: 

That's not how PTYs work; you should read man 4 pty and man 4 pts. (The old BSD-style devices should no longer be used.)

In order to open a pseudo-terminal slave (PTS, the /dev/pts/# returned by ptsname(3)), another program must create a pseudo-terminal master (PTM, returned by posix_openpt(3)) and enable the PTS with grantpt(3) and unlockpt(3).

Using the forkpty(3) etc. helper functions is a lot easier than calling the low-level functions yourself.

And even after that, it doesn't work like a FIFO (which you seem to be expecting): anything written into the PTS comes out on the PTM, and anything read from the PTS is written from the PTM.

ephemient