public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
From: "mac at mcrowe dot com" <sourceware-bugzilla@sourceware.org>
To: glibc-bugs@sourceware.org
Subject: [Bug stdio/17830] New: dprintf fails when file descriptor is connected to /dev/kmsg
Date: Mon, 12 Jan 2015 12:33:00 -0000	[thread overview]
Message-ID: <bug-17830-131@http.sourceware.org/bugzilla/> (raw)

https://sourceware.org/bugzilla/show_bug.cgi?id=17830

            Bug ID: 17830
           Summary: dprintf fails when file descriptor is connected to
                    /dev/kmsg
           Product: glibc
           Version: 2.21
            Status: NEW
          Severity: normal
          Priority: P2
         Component: stdio
          Assignee: unassigned at sourceware dot org
          Reporter: mac at mcrowe dot com

If the file descriptor passed to dprintf is connected to /dev/kmsg on a modern
Linux kernel then dprintf fails (apparently because /dev/kmsg does not support
seeking.)

Steps to reproduce:

1. Run a Linux kernel with new-style /dev/kmsg (I was running Debian Jessie's
v3.16 kernel but others as old as v3.8 show the same symptom.)

2. Compile the following code:

 #include <stdio.h>
 int main()
 {
     int r = dprintf(1, "test\n");
     fprintf(stderr, "Result: %d %m\n", r);
     return 0;
 }

3. Run ./a.out and the result is as expected

 test
 Result: 5 Success

4. Run "./a.out >/dev/kmsg" and dprintf fails:

 Result: -1 Bad file descriptor

 and no output appears in the kernel log.

Expected result:

 dprintf should work just as well on /dev/kmsg as anything else.


Reproduced in Debian Jessie's glibc v2.19 and glibc master at
56cf2763819d2f721c98f2b8bcc04a3c673837d3.

-- 
You are receiving this mail because:
You are on the CC list for the bug.


             reply	other threads:[~2015-01-12 12:33 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-12 12:33 mac at mcrowe dot com [this message]
2015-01-12 12:34 ` [Bug stdio/17830] " mac at mcrowe dot com
2015-01-15 11:13 ` schwab@linux-m68k.org
2015-01-15 11:22 ` schwab@linux-m68k.org
2015-01-15 15:42 ` mac at mcrowe dot com
2015-01-15 15:57 ` mac at mcrowe dot com
2015-01-15 17:46 ` mac at mcrowe dot com
2015-01-30  4:58 ` bugdal at aerifal dot cx
2015-01-30 10:38 ` schwab@linux-m68k.org
2015-01-30 15:19 ` bugdal at aerifal dot cx

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=bug-17830-131@http.sourceware.org/bugzilla/ \
    --to=sourceware-bugzilla@sourceware.org \
    --cc=glibc-bugs@sourceware.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).