gets() timeout

I need a fonction like gets() with a timeout.
How can I do ?

bruno <bruno.suarez@scola.ac-paris.fr> wrote:

I need a fonction like gets() with a timeout.
How can I do ?

open(…, O_NONBLOCK), select(), and read(),
or
open(…, O_NONBLOCK), ionotify(), and read().
or (crude)
alarm(seconds); gets();
or (not quite as crude, but still moderately nasty, and depends on gets()
only going into a SEND or REPLY state once)
TimerTimeout( ); gets();

-David

David Gibbs wrote:

bruno <> bruno.suarez@scola.ac-paris.fr> > wrote:
I need a fonction like gets() with a timeout.
How can I do ?

open(…, O_NONBLOCK), select(), and read(),
or
open(…, O_NONBLOCK), ionotify(), and read().
or (crude)
alarm(seconds); gets();
or (not quite as crude, but still moderately nasty, and depends on gets()
only going into a SEND or REPLY state once)
TimerTimeout( ); gets();

-David

Can I use readcond()

bruno <bruno.suarez@scola.ac-paris.fr> wrote:

David Gibbs wrote:

bruno <> bruno.suarez@scola.ac-paris.fr> > wrote:
I need a fonction like gets() with a timeout.
How can I do ?

open(…, O_NONBLOCK), select(), and read(),
or
open(…, O_NONBLOCK), ionotify(), and read().
or (crude)
alarm(seconds); gets();
or (not quite as crude, but still moderately nasty, and depends on gets()
only going into a SEND or REPLY state once)
TimerTimeout( ); gets();

-David

Can I use readcond()

Sure, but the advantage of the open(),select(),read() combination is
that they are all “standard” calls – open() and read() are Posix,
select() is “standard Unix”. readcond() (like ionotify() and
TimerTimeout()) is Neutrino only. If future portability isn’t an
issue, feel free to use readcond(). With readcond() be careful to
read the documentation on the interaction of the different flags
carefully.

(For those with a QNX4 background, readcond() looks a lot like
dev_read(), but without the ability to arm an event for later
notification.)

-David