bug-hurd
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

fileno(tmpfile()) returns EBADF


From: Marcus Brinkmann
Subject: fileno(tmpfile()) returns EBADF
Date: Tue, 16 Apr 2002 22:56:14 -0400
User-agent: Mutt/1.3.25i

Hi,

the following program returns EBADF from fileno on the Hurd, this breaks
new_tmpfile in perl completely (because perl has a one-for-all open
routine which always examines the file pointer thoroughly).
This was also caught by the perl test harnish.

Thanks,
Marcus

#define _GNU_SOURCE 1
#include <unistd.h>
#include <stdio.h>
#include <sys/stat.h>
#include <errno.h>
#include <string.h>
#include <error.h>

main()
{
  FILE *fp;
  int fd;
  struct stat statbuf;

  fp = tmpfile();
  if (!fp)
    error (1, errno, "tmpfile");
  fd = fileno (fp);
  if (fd == -1)
    error (1, errno, "fileno");
  if (fstat (fd, &statbuf) < 0)
    error (1, errno, "fstat");
}
                  



reply via email to

[Prev in Thread] Current Thread [Next in Thread]