Unix Programming - Best way to check when pty slave has closed?

This is Interesting: Free IT Magazines  
Home > Archive > Unix Programming > November 2007 > Best way to check when pty slave has closed?





You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

Author Best way to check when pty slave has closed?
Boltar

2007-11-22, 1:23 pm

HI

I've got a program that spawns of a child and the parent and child
communicate via a pty master-slave pair. Problem is , when the child
closes the slave pty file descriptor no notification comes through the
the parent - it carries on sitting in select() on the master fd.

Is there a way to check for when the slave has been closed (on linux)?

Thanks for any help

B2003
Casper H.S. Dik

2007-11-22, 1:23 pm

Boltar <boltar2003@yahoo.co.uk> writes:

>I've got a program that spawns of a child and the parent and child
>communicate via a pty master-slave pair. Problem is , when the child
>closes the slave pty file descriptor no notification comes through the
>the parent - it carries on sitting in select() on the master fd.


>Is there a way to check for when the slave has been closed (on linux)?


Does the parent keep a filedescriptor pointing to the slave side open?

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Boltar

2007-11-22, 1:23 pm

On Nov 22, 4:17 pm, Casper H.S. Dik <Casper....@Sun.COM> wrote:
> Boltar <boltar2...@yahoo.co.uk> writes:
>
> Does the parent keep a filedescriptor pointing to the slave side open?


Yes it does. Should it close it?

B2003

Rainer Weikusat

2007-11-22, 1:23 pm

Boltar <boltar2003@yahoo.co.uk> writes:
> On Nov 22, 4:17 pm, Casper H.S. Dik <Casper....@Sun.COM> wrote:
>
> Yes it does. Should it close it?


As long as input would still be possible from the slave, ie there
exists an open descriptor, the master will not see an EOF.
Casper H.S. Dik

2007-11-22, 1:23 pm

Boltar <boltar2003@yahoo.co.uk> writes:

>On Nov 22, 4:17 pm, Casper H.S. Dik <Casper....@Sun.COM> wrote:
[vbcol=seagreen]
>Yes it does. Should it close it?


Yes; the parent will only be notified of a close if the last slave
file descriptor is closed.

Casper
--
Expressed in this posting are my opinions. They are in no way related
to opinions held by my employer, Sun Microsystems.
Statements on Sun products included here are not gospel and may
be fiction rather than truth.
Boltar

2007-11-22, 1:23 pm

On Nov 22, 5:45 pm, Casper H.S. Dik <Casper....@Sun.COM> wrote:
>
> Yes; the parent will only be notified of a close if the last slave
> file descriptor is closed.


Works now. Thanks

B2003

Sponsored Links






Free braindumps | Software forum | Database administration forum

Copyright 2003 - 2008 webservertalk.com