From owner-freebsd-hackers Thu May 2 22:35:25 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.3/8.7.3) id WAA29396 for hackers-outgoing; Thu, 2 May 1996 22:35:25 -0700 (PDT) Received: from cs.utah.edu (cs.utah.edu [128.110.4.21]) by freefall.freebsd.org (8.7.3/8.7.3) with SMTP id WAA29389 for ; Thu, 2 May 1996 22:35:20 -0700 (PDT) Received: from bottles.cs.utah.edu by cs.utah.edu (8.6.12/utah-2.21-cs) id XAA28094; Thu, 2 May 1996 23:35:19 -0600 Received: by bottles.cs.utah.edu (8.6.10/utah-2.15-leaf) id XAA08058; Thu, 2 May 1996 23:35:19 -0600 From: sclawson@bottles.cs.utah.edu (steve clawson) Message-Id: <199605030535.XAA08058@bottles.cs.utah.edu> Subject: stdio and freopen() To: freebsd-hackers@freebsd.org Date: Thu, 2 May 96 23:35:18 MDT X-Mailer: ELM [version 2.3 PL11] Sender: owner-hackers@freebsd.org X-Loop: FreeBSD.org Precedence: bulk At this point I'm sure that everyone really couldn't care less, and I didn't heed my own warning to just get some sleep...so of course I've got another patch for freopen() that is perhaps a little more reasonable than the first, so that if you're doing something strange and had opened the stream with funopen() you don't loose. steve *** /usr/arch/FreeBSD/current/lib/libc/stdio/freopen.c Tue May 30 04:35:17 1995 --- freopen.c Thu May 2 23:25:46 1996 *************** *** 94,99 **** --- 94,106 ---- /* Get a new descriptor to refer to the new file. */ f = open(file, oflags, DEFFILEMODE); + if (isopen && (f == fp->_file)) { + close(f); + (void) (*fp->_close)(fp->_cookie); + isopen = 0; + wantfd = -1; + f = open(file, oflags, DEFFILEMODE); + } if (f < 0 && isopen) { /* If out of fd's close the old one and try again. */ if (errno == ENFILE || errno == EMFILE) { -- // stephen clawson sclawson@cs.utah.edu // university of utah