Path: utzoo!news-server.csri.toronto.edu!cs.utexas.edu!swrinde!zaphod.mps.ohio-state.edu!think.com!snorkelwacker.mit.edu!bloom-picayune.mit.edu!athena.mit.edu!jik From: jik@athena.mit.edu (Jonathan I. Kamens) Newsgroups: comp.unix.questions Subject: Re: Redirection of stderr Keywords: stderr Message-ID: <1991Mar14.225058.13507@athena.mit.edu> Date: 14 Mar 91 22:50:58 GMT References: <574@dprmpt.UUCP> <1991Mar14.220650.11736@athena.mit.edu> Sender: news@athena.mit.edu (News system) Distribution: na Organization: Massachusetts Institute of Technology Lines: 29 Someone has pointed out to me in E-mail that assigning to stderr as I indicated in my previous message won't work on many systems because of the way stderr is defined. There are ways to get around this. One of them, a rather gross method that will nonetheless work on many systems, is to assign to stderr like this: *(stderr) = *(value to assign) e.g. *(stderr) = *(fopen(error_file, "w")); However, this won't work if FILE * is an opaque type whose contents are not spelled out for the compiler in . It is possible to replace stderr with a file doing something like this: freopen(error_file, "w", stderr); However, if you do things this way, I can't see any way to put the original stderr back in place -- there is no "fdreopen". That's unfortunate. -- Jonathan Kamens USnail: MIT Project Athena 11 Ashford Terrace jik@Athena.MIT.EDU Allston, MA 02134 Office: 617-253-8085 Home: 617-782-0710