From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from euclid.skiles.gatech.edu (euclid.skiles.gatech.edu [130.207.146.50]) by melb.werple.net.au (8.7.4/8.7.3) with ESMTP id HAA25791 for ; Wed, 13 Mar 1996 07:41:23 +1100 (EST) Received: (from list@localhost) by euclid.skiles.gatech.edu (8.7.3/8.7.3) id PAA11904; Tue, 12 Mar 1996 15:26:53 -0500 (EST) Resent-Date: Tue, 12 Mar 1996 15:26:53 -0500 (EST) From: Zoltan Hidvegi Message-Id: <199603122026.VAA10349@bolyai.cs.elte.hu> Subject: Re: Buffered stderr on Linux To: schaefer@nbn.com Date: Tue, 12 Mar 1996 21:26:05 +0100 (MET) Cc: zsh-workers@math.gatech.edu In-Reply-To: <9603121124.ZM2604@candle.brasslantern.com> from Bart Schaefer at "Mar 12, 96 11:24:25 am" Organization: Dept. of Comp. Sci., Eotvos University, Budapest, Hungary Phone: (36 1)2669833 ext: 2667, home phone: (36 1) 2752368 X-Mailer: ELM [version 2.4ME+ PL11 (25)] Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Resent-Message-ID: <"4SFS_.0.tv2.CuTHn"@euclid> Resent-From: zsh-workers@math.gatech.edu X-Mailing-List: archive/latest/814 X-Loop: zsh-workers@math.gatech.edu Precedence: list Resent-Sender: zsh-workers-request@math.gatech.edu 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