Date: Thu, 2 May 96 23:35:18 MDT From: sclawson@bottles.cs.utah.edu (steve clawson) To: freebsd-hackers@freebsd.org Subject: stdio and freopen() Message-ID: <199605030535.XAA08058@bottles.cs.utah.edu>
next in thread | raw e-mail | index | archive | help
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
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605030535.XAA08058>