freopen()





Hi,

I am a bit confused about the behaviour of freopen() and the standard
i/o streams.

I am trying to redirect a stream (stderr) to a particular "file". But,
if the call fails I want it to stay as it was, or at least be able to
redirect it somewhere else (e.g. stdout).

For example I would like to do,

..
stderr = freopen("/dev/errors","w", stderr); /* may fail */
if(!stderr) freopen("/dev/screen", "w", stderr);


--

John Devereux
.



Relevant Pages

  • Re: [kde] KDE strerr?
    ... It goes by default to .xsession-errors, however an app may ... redirect, or you may redirect to where ever you want. ... error) as an output is more a standard interface than a destination. ... just sends the error to "stderr" its up to you, the OS, the app, or in this ...
    (KDE)
  • Re: freopen usage
    ... I have a question regarding the standard C library. ... void main ... guarantee that the output of perror() will be meaningful. ... I can redirect stdin in the first program and can open ...
    (comp.lang.c.moderated)
  • Re: redirect the output to a file
    ... you have two commands executed in sequence. ... That will cause all output from /make/ to stdout to be sent to ... error messages sent to stderr will only go to the screen. ... Will first redirect stderr to stdout, then send it all to /tee/. ...
    (comp.os.linux.misc)
  • Re: problem closing stdout
    ... ioTaskStdSet- set the file descriptor for task standard input/ ... able to successfully redirect the stdout to pipe. ...
    (comp.os.vxworks)
  • SUMMARY: Solaris 8: Redirect standard error two places
    ... I have been struggling to redirect standard error and standard out how I ... What I am trying to accomplish is redirecting standard error to a log file ...
    (SunManagers)