How do I control the master, i.e. send start/stop characters, detect
hangup and send signals (e.g. SIGTERM) to the process connected to the
slave fd?
Olga
On Wed, Mar 24, 2010 at 1:22 AM, Edward Pilatowicz
<edward.pilatowicz at sun.com> wrote:
> On Wed, Mar 24, 2010 at 01:16:28AM +0100, ????? ???????????? wrote:
>> Yes, I was looking for the SUS API to create a pty master/slave pair, i.e.
>> int fd_master, fd_slave;
>> char *slave; ...
>> fd_master = open("/dev/ptmx", O_RDWR);
>> grantpt(fd_master);
>> unlockpt(fd_master);
>> slave = ptsname(fd_master);
>> fd_slave = open(slave, O_RDWR);
>>
>> Now when I created the master, how to I pass the slave to a shell?
>> Just dup(fd_slave) for stdin, stdout, stderr and pass it to
>> fork()/exec()? Or do I have to use open()? Or just open once and pass
>> the same fd for stdin, stdout, stderr to the shell?
>>
>
> you probably want to do the dup() after the fork and before the exec().
> having the same fd for stdin, stdou, and stderr sounds right.
>
> ed
>
>> Olga
>>
>> On Wed, Mar 24, 2010 at 1:10 AM, Edward Pilatowicz
>> <edward.pilatowicz at sun.com> wrote:
>> > On Wed, Mar 24, 2010 at 12:57:40AM +0100, ????? ???????????? wrote:
>> >> I am looking for an example for the user land pty/pseudo-terminal API
>> >> to implement custom master/slaves (without setid). Does anyone have
>> >> pointers?
>> >>
>> >
>> > i'm not totally sure i understand the question, but it sounds like your
>> > asking for pointers to the open("/dev/ptmx"), grantpt(3c), ptsname(3C),
>> > unlockpt(3C), posix interfaces.
>> >
>> > ed
>> >
>>
>>
>>
>> --
>> , _ _ ,
>> { \/`o;====- Olga Kryzhanovska -====;o`\/ }
>> .----'-/`-/ olga.kryzhanovska at gmail.com \-`\-'----.
>> `'-..-| / Solaris/BSD//C/C++ programmer \ |-..-'`
>> /\/\ /\/\
>> `--` `--`
>
--
, _ _ ,
{ \/`o;====- Olga Kryzhanovska -====;o`\/ }
.----'-/`-/ olga.kryzhanovska at gmail.com \-`\-'----.
`'-..-| / Solaris/BSD//C/C++ programmer \ |-..-'`
/\/\ /\/\
`--` `--`