This is the mail archive of the glibc-bugs@sources.redhat.com 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 libc/814] New: perror(3) generates an error


The perror(3) function generates an error that "overwrites" errno value.

Try to compile and run the code below and you'll get:
open: Success
write: Illegal seek
close: Illegal seek

However manpage for errno(3) says that errno is meaningful only after an
errornous call, IMHO perror should not change it's value. I suggest
restoring the errno(3) value just befor return from perror(3).

As i watched the strace(1) output for the example programme there was an _lseek
call which returned an ESPIPE.

-----EXAMPLE CODE-----
#include <stdio.h>
#include <fcntl.h>

int main(int ac, char* av[]) {
        int fd;

        fd=open("/dev/null", O_WRONLY);
        perror("open");

        write(fd, "/dev/null", 10);
        perror("write");

        close(fd);
        perror("close");

        return 0;
}
-----EXAMPLE CODE------

-- 
           Summary: perror(3) generates an error
           Product: glibc
           Version: 2.3.4
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: steelman at post dot pl
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i486-slackware-linux
  GCC host triplet: i486-slackware-linux
GCC target triplet: i486-slackware-linux


http://sources.redhat.com/bugzilla/show_bug.cgi?id=814

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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