Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.os.linux.development.apps > #298

Re: How to dup a FILE*

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!weretis.net!feeder4.news.weretis.net!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail
From David W Noon <dwnoon@spamtrap.ntlworld.com>
Newsgroups comp.os.linux.development.apps
Subject Re: How to dup a FILE*
Date Tue, 6 Dec 2011 19:53:33 +0000
Organization Luton Operatic Society
Lines 23
Message-ID <20111206195333.49dd7a9d@dwnoon.ntlworld.com> (permalink)
References <jbkl2v$a75$1@nntp.ts.fujitsu.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding base64
Injection-Info mx04.eternal-september.org; posting-host="H8DOh31pSOx4nH+KEGiP4w"; logging-data="7702"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19rfD412vqlximzUgMUuPfi"
X-Newsreader Claws Mail 3.7.10 (GTK+ 2.24.5; i686-pc-linux-gnu)
Cancel-Lock sha1:91tfTOA+VwF0YyHljFFuxzb/Jog=
Xref x330-a1.tempe.blueboxinc.net comp.os.linux.development.apps:298

Show key headers only | View raw


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

On Tue, 06 Dec 2011 09:51:43 +0100, Josef Moellers wrote about How to
dup a FILE*:

>I need to juggle with stderr: redirecting it from one file to another
>and back.
[snip]

I think you're over-complicating things here.  After all, stderr is
simply a pointer.  So, cache the old pointer; open a new file stream
stored in stderr; fclose(stderr) when done; reinstate the original
pointer.  E.g.

     FILE * old_stderr = stderr;

     stderr = fopen(new_file_name, "w");
     /* Do some stuff with errors logged to new file. */
     . . .
     . . .
     /* Finished with new error log. */
     fclose(stderr);

     /* Restore old stderr pointer. */
     stderr = old_stderr;
- -- 
Regards,

Dave  [RLU #314465]
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
dwnoon@spamtrap.ntlworld.com (David W Noon)
Remove spam trap to reply by e-mail.
*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*-*
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.17 (GNU/Linux)

iEYEARECAAYFAk7ecsQACgkQ9MqaUJQw2MmYAACfS2Hg5vVZPAufaCRJZf33TDQM
3HAAmwc8WaQ+ENpTShrn9zy4kY8g/MKK
=wJFD
-----END PGP SIGNATURE-----

Back to comp.os.linux.development.apps | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

How to dup a FILE* Josef Moellers <josef.moellers@ts.fujitsu.com> - 2011-12-06 09:51 +0100
  Re: How to dup a FILE* Richard Kettlewell <rjk@greenend.org.uk> - 2011-12-06 09:16 +0000
    Re: How to dup a FILE* Josef Moellers <josef.moellers@ts.fujitsu.com> - 2011-12-06 10:41 +0100
  Re: How to dup a FILE* Jasen Betts <jasen@xnet.co.nz> - 2011-12-06 13:28 +0000
    Re: How to dup a FILE* Josef Moellers <josef.moellers@ts.fujitsu.com> - 2011-12-06 16:57 +0100
  Re: How to dup a FILE* David W Noon <dwnoon@spamtrap.ntlworld.com> - 2011-12-06 19:53 +0000
    Re: How to dup a FILE* Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-12-06 20:38 +0000
      Re: How to dup a FILE* Richard Kettlewell <rjk@greenend.org.uk> - 2011-12-06 22:03 +0000
      Re: How to dup a FILE* David W Noon <dwnoon@spamtrap.ntlworld.com> - 2011-12-06 21:46 +0000
        Re: How to dup a FILE* Rainer Weikusat <rweikusat@mssgmbh.com> - 2011-12-07 17:52 +0000

csiph-web