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]

[Bug stdio/14131] New: Request for freopencookie function


http://sourceware.org/bugzilla/show_bug.cgi?id=14131

             Bug #: 14131
           Summary: Request for freopencookie function
           Product: glibc
           Version: 2.15
            Status: NEW
          Severity: enhancement
          Priority: P2
         Component: stdio
        AssignedTo: unassigned@sourceware.org
        ReportedBy: dcgloe@gmail.com
    Classification: Unclassified


A program I am working on writes logs using a message format containing a
timestamp. We also use some libraries which print information to stderr and
stdout, so we redirect them to our log file using freopen.

The issue is that the messages from stdout and stderr redirected with freopen
don't conform to our log format. fopencookie would allow us to add a timestamp
to all messages, but it doesn't support redirection of an existing stream. What
we need is a function analagous to freopen with cookies (I would propose naming
it freopencookie).

>From here
(http://www.gnu.org/software/libc/manual/html_node/Standard-Streams.html) it
seems that stdout and stderr are assignable, so a workaround for now would be
to do
fclose(stdout);
stdout = fopencookie(cookie, mode, io_funcs);

This solution has slightly less portability because stdout won't be assignable
on all systems, but I suppose code using fopencookie isn't meant to be
particularly portable in the first place.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


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