This is the mail archive of the glibc-bugs@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

fprintf control from Environment variable.


Dear All,

I want to control the print message being sent to stdout and stderr
using printf(), vprintf() and fprintf() function call for better
performance.

For this I have added following code in vfprintf() function
  static int Verbose = 0;
  if(stream == stdout || stream == stderr)
  {
      if (Verbose == 0)
     Verbose = getenv ("PRINT") ? 1 : 2;
      if (Verbose == 1)
     return 0;
  }
 Thus, if  PRINT is being set as an environment variable then print
messages being controlled and not getting displayed.
I checked that printf, vprintf and fprintf all calls vfprintf() function.

In this, I am facing issue that print messages send through fprintf()
call are not getting controlled and still coming on stdout or stderr.

I checked that for fprintf() call if stream is other then stdout or
stderr then code flows comes to vfprintf() function and if stream is
stdout or stderr then code flow is different and fwrite() function is
getting called.
Please find obj-dump for fprintf() call
  fprintf(stdout, "fprintf stdout!\n");
   8048662:       a1 80 9b 04 08          mov    0x8049b80,%eax
   8048667:       89 c2                   mov    %eax,%edx
   8048669:       b8 54 88 04 08          mov    $0x8048854,%eax
   804866e:       89 54 24 0c             mov    %edx,0xc(%esp)
   8048672:       c7 44 24 08 10 00 00    movl   $0x10,0x8(%esp)
   8048679:       00
   804867a:       c7 44 24 04 01 00 00    movl   $0x1,0x4(%esp)
   8048681:       00
   8048682:       89 04 24                mov    %eax,(%esp)
   8048685:       e8 76 fd ff ff          call   8048400 <fwrite@plt>

Please let me know the way using which print messages invoked using
fprintf() call can be controlled if send to stdout ot stderr stream.

Thanks


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]