On Mon, Oct 09, 2000 at 01:24:16PM +0200, Piotr Piatkowski wrote:
> On Mon, 9 Oct 2000, Nicholas Clark wrote:
> 
> > Linux says:
> > 
> > RETURN VALUES
> >        Upon  successful  completion  fopen,  fdopen  and  freopen
> >        return  a  FILE  pointer.  Otherwise, NULL is returned and
> >        the global variable errno is set to indicate the error.
> 
> Solaris has more:
> 
>      The fopen() function may fail and not set errno if there are
>      no free stdio streams.

Ah. so I was wrong. :-)
But this doesn't make Solaris helpful.
 
> Also:
> 
>      The number of streams that a process can have  open  at  one
>      time  is  STREAM_MAX.  If  defined, it has the same value as
>      FOPEN_MAX.
> 
> ...which is not all correct, because you can open 256 files by "raw" open,
> then be unable to open *any* stream by fopen. 

Yep. I agree that that documentation isn't correct.
I had this problem with some software (written in C++) at a previous employer.
C++ would merrily open a lot of file descriptors (>256). The software would
then call the Oracle libraries, which would attempt to open tnsnames.ora
using stdio. This fopen() would fail, and the software would hang.
(However, the C++ software was very buggy, so I don't know if the hang was
due to it not coping with documented Oracle call failure)

> > perlfunc does say:

> Oh, I have missed this one, mea culpa :-)

I didn't know it was there until today. It's easy to miss; there's really
too much documentation for open. Which I've just made worse.

> > but doesn't document this w.r.t. general open. Would this be useful:
> [...]
> 
> Hmm... Perl could notice such case (when fdopen failed but didn't set
> errno) and emit some warning to not confuse programmers with errors
> without $! set.

That thought occurred to me when I read your quote of the man page.
It seems a sensible way to go, if it works in such a way so as not to
confuse any other OS.
> 
> But I'll try to prepare some patch for this, then post it here for your
> opinion.
> 
> For now, I'll try with sfio. 

Good luck. Assuming you run the regression tests to check your perl build,
I believe that op/misc test 48 fails under sfio (and all others now pass)

Nicholas 

Reply via email to