This is the mail archive of the libc-alpha@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]

FreeBSD port (42): ptsname


The tst-grantpt test fails since grantpt returns with errno = EINVAL
(converted from ENOTTY in sysdeps/unix/grantpt.c) when it ought to return
with errno = EBADF. Since you are apparently not seeing the same failure
on Linux or Hurd, the fix must go into sysdeps/unix/bsd/ptsname.c. (It
cannot go into sysdeps/unix/bsd/isatty.c because it is wrong to assume
that isatty sets errno when it returns 0.)


2002-09-05  Bruno Haible  <bruno@clisp.org>

	* sysdeps/unix/bsd/ptsname.c (__ptsname_r): Return with errno = EBADF
	if fd is an invalid file descriptor.

diff -r -c3 glibc-20020828.bak/sysdeps/unix/bsd/ptsname.c glibc-20020828/sysdeps/unix/bsd/ptsname.c
*** glibc-20020828.bak/sysdeps/unix/bsd/ptsname.c	Tue Jul 10 23:01:20 2001
--- glibc-20020828/sysdeps/unix/bsd/ptsname.c	Thu Sep  5 03:43:55 2002
***************
*** 1,4 ****
! /* Copyright (C) 1998 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
  
     The GNU C Library is free software; you can redistribute it and/or
--- 1,4 ----
! /* Copyright (C) 1998, 2002 Free Software Foundation, Inc.
     This file is part of the GNU C Library.
  
     The GNU C Library is free software; you can redistribute it and/or
***************
*** 17,22 ****
--- 17,23 ----
     02111-1307 USA.  */
  
  #include <errno.h>
+ #include <fcntl.h>
  #include <paths.h>
  #include <stdlib.h>
  #include <string.h>
***************
*** 54,61 ****
  
    if (!__isatty (fd))
      {
!       __set_errno (ENOTTY);
!       return ENOTTY;
      }
  
    if (buflen < strlen (_PATH_TTY) + 3)
--- 55,72 ----
  
    if (!__isatty (fd))
      {
!       /* We cannot assume that __isatty has set errno.  Therefore we need
! 	 to call fcntl() to distinguish between EBADF and ENOTTY.  */
!       if (__fcntl (fd, F_GETFD, 0) < 0)
! 	{
! 	  __set_errno (EBADF);
! 	  return EBADF;
! 	}
!       else
! 	{
! 	  __set_errno (ENOTTY);
! 	  return ENOTTY;
! 	}
      }
  
    if (buflen < strlen (_PATH_TTY) + 3)


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