Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: Buffered stderr on Linux



Bart Schaefer wrote:
> On Mar 12,  8:03pm, Zoltan Hidvegi wrote:
> } Subject: Buffered stderr on Linux
> }
> } Now I wander why is it
> } necessary to use malloc to allocate these buffers.  Is there anything
> } against using static char[BUFSIZ] buffers?
> 
> Stdio will call free() on the buffer at fclose().  That means you should
> always pass malloc'd buffers, and never call free() yourself on a buffer
> that's been passed to any of the setbuf() variants!

As far as I know zsh never closes stdout and stderr explicitely.  Of course
there is an implicit close on exit() (but not on _exit() which zsh use when
it forked) and a free may fail here but it is probably harmless.  Anyway it
is probably better to stay clean and use malloc.

Zoltan




Messages sorted by: Reverse Date, Date, Thread, Author