[Date Prev][Date Next][Thread Prev][Thread Next]
[Date Index]
[Thread Index]
- Subject: Re: lua bug - loadfile gets stdin confused
- From: David Kastrup <dak@...>
- Date: Thu, 19 Apr 2007 08:45:17 +0200
Luiz Henrique de Figueiredo <lhf@tecgraf.puc-rio.br> writes:
>> For windows:
>>
>> _get_osfhandle(_fileno(stdout)) > 0
>>
>> means valid.
>
> Unix has fileno, but if stdio is recycling FILE* then it probably is
> also recycling filenos. So opening a file right after closing stdin
> will probably create a file whose fileno is 0. That's the whole
> problem.
It is actually an old idiom in Unix to close those file descriptors
and expect them to open from the beginning. It predates doing this by
dup2 and similar calls.
--
David Kastrup