This is the mail archive of the
glibc-bugs@sourceware.org
mailing list for the glibc project.
[Bug stdio/17909] New: getline/getdelim sets errno to ENOTTY after trying to read from /dev/null
- From: "luther.ansynod at yopmail dot com" <sourceware-bugzilla at sourceware dot org>
- To: glibc-bugs at sourceware dot org
- Date: Fri, 30 Jan 2015 16:26:25 +0000
- Subject: [Bug stdio/17909] New: getline/getdelim sets errno to ENOTTY after trying to read from /dev/null
- Auto-submitted: auto-generated
https://sourceware.org/bugzilla/show_bug.cgi?id=17909
Bug ID: 17909
Summary: getline/getdelim sets errno to ENOTTY after trying to
read from /dev/null
Product: glibc
Version: unspecified
Status: NEW
Severity: normal
Priority: P2
Component: stdio
Assignee: unassigned at sourceware dot org
Reporter: luther.ansynod at yopmail dot com
On Linux, if I run the test program below with stdin redirected from
a normal empty file, I get the following output, as expected:
$ touch empty-file
$ ./getline-test < empty-file
rval: -1, feof: 1, ferror: 0, errno: 0 (Success)
However, if I try to read from /dev/null, I get the following:
$ ./getline-test < /dev/null
rval: -1, feof: 1, ferror: 0, errno: 25 (Inappropriate ioctl for device)
errno 25 is ENOTTY, which is not one of the error values that
getline/getdelim should return, according to POSIX
<http://pubs.opengroup.org/onlinepubs/9699919799/functions/getdelim.html>
I would expect errno to be 0 in this case, as no error occurred, from
the point of view of the caller of getline().
//----------------------------------------
// getline-test.c
#include <errno.h>
#include <stdio.h>
#include <stdlib.h>
int
main (int arg, char **argv)
{
char *bufp = NULL;
size_t bufsize = 0;
ssize_t rval;
int err;
errno = 0;
rval = getline (&bufp, &bufsize, stdin);
err = errno;
printf ("rval: %d, feof: %d, ferror: %d, errno: %d (%s)\n",
rval, feof (stdin), ferror (stdin), err, strerror (err));
free (bufp);
return 0;
}
--
You are receiving this mail because:
You are on the CC list for the bug.