Re: how does a pts for child process get set?
- From: Rainer Weikusat <rweikusat@xxxxxxxxxxx>
- Date: Wed, 28 Apr 2010 14:18:13 +0200
Joel Fernandes <agnel.joel@xxxxxxxxx> writes:
On Apr 25, 11:26 pm, Rainer Weikusat <rweiku...@xxxxxxxxxxx> wrote:
The process which opened the slave pty (either parent or child) called
the ptsname(3)-routine to determine the name of the 'inferior device'
corresponding to the existing file descriptor for the master half of
Hi, Thanks a lot for your message.
I am bit confused about ptsname. Once the parent opens the master ptty
file (ptmx).. how does the child process get access to this fd? I
thought this is how it worked:
1. parent opens the /dev/ptmx file
2. calls ptsname on the master fd
4. opens name returned by ptsname
5. execs image of child
So the opening of the slave (pts) file has to be done by the parent
'Parent' usually refers to the process which calls 'fork' and 'child' to
the process created by fork. Except if the FD_CLOEXEC flag
is set for a file descriptor, the program executed by the exec-call
inherits all open file descriptors and consequently, the program which
is executed could open theoretically the slave pty
itself. Practically, there must be code to implement this and the
executed program would need to know which descriptor number
corresponds to the pty master, so this won't usually happen.