On 19 May 2014 20:15, Aram Hăvărneanu wrote: > Some people claimed > that using it leaked file descriptors in multithreaded programs. I > don't understand why this problem can't be solved by opening it > close-on-exec. > The optimisation was a static int file descriptor. That was troublesome in the context of processes that shared memory but not file descriptor groups, or somehow rearranged descriptors and then called time/nsec again. A fork and syslog might be enough. The improved version cached file descriptors per-process, but using a table with an entry per-process (but only up to 64, when it reverted to earlier behaviour) and using a process ID in _tos. Since a library function has no idea what's happening in rfork(), or In case file descriptors had been closed meanwhile, it would retry once(!). In some cases, that might lead it to read from a file descriptor that was open, but not on the time, causing much confusion. Further elaboration of the mechanism had been proposed to deal with that. I prefer one or other Gordian Knot technique, myself.