This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[Bug manual/17459] Manual doesn't mention that timeout argument of select can be modified


https://sourceware.org/bugzilla/show_bug.cgi?id=17459

--- Comment #1 from Michael Kerrisk <mtk.manpages at gmail dot com> ---
(In reply to Gavin Smith from comment #0)
> In the "Waiting for I/O" node of the manual (which is in the
> manual/llio.texi file), in the description of the "select" function, it is
> mentioned that you can timeout waiting for input or output by passing a
> pointer to a struct timeval object to "select". However, it doesn't say that
> select can overwrite this object. This led to a problem when I tried to
> reuse the struct timeval object in a loop with a select call.

Confirmed. POSIX permits this behavior. The select(2) man page documents this
point:

       On Linux, select() modifies timeout to reflect  the  amount  of
       time  not  slept;  most  other  implementations do not do this.
       (POSIX.1-2001 permits either behavior.)  This  causes  problems
       both  when  Linux  code  which reads timeout is ported to other
       operating systems, and when code is ported to Linux that reuses
       a  struct  timeval  for  multiple  select()s  in a loop without
       reinitializing it.  Consider  timeout  to  be  undefined  after
       select() returns.

A fix to the glibc manual is probably in order.

Cheers,

Michael

-- 
You are receiving this mail because:
You are on the CC list for the bug.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]