From nobody@FreeBSD.org  Fri Apr  5 04:14:55 2002
Return-Path: <nobody@FreeBSD.org>
Received: from freefall.freebsd.org (freefall.FreeBSD.org [216.136.204.21])
	by hub.freebsd.org (Postfix) with ESMTP id 5DFA537B405
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  5 Apr 2002 04:14:55 -0800 (PST)
Received: (from nobody@localhost)
	by freefall.freebsd.org (8.11.6/8.11.6) id g35CEtL66960;
	Fri, 5 Apr 2002 04:14:55 -0800 (PST)
	(envelope-from nobody)
Message-Id: <200204051214.g35CEtL66960@freefall.freebsd.org>
Date: Fri, 5 Apr 2002 04:14:55 -0800 (PST)
From: Murray Nesbitt <murray@unixporting.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Can't fcntl(fd, F_SETFL, ...) on a pseudo-tty
X-Send-Pr-Version: www-1.0

>Number:         36784
>Category:       kern
>Synopsis:       Can't fcntl(fd, F_SETFL, ...) on a pseudo-tty
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    jh
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Apr 05 04:20:01 PST 2002
>Closed-Date:    Thu Apr 29 18:24:03 UTC 2010
>Last-Modified:  Thu Apr 29 18:24:03 UTC 2010
>Originator:     Murray Nesbitt
>Release:        4.5-RELEASE
>Organization:
>Environment:
FreeBSD bp6.unixporting.com 4.5-RELEASE FreeBSD 4.5-RELEASE #0: Tue Apr  2 05:09:44 GMT 2002 root@bp6.unixporting.com:/usr/src/sys/compile/MYKERNEL.bp6  i386
>Description:

fcntl(fd, F_SETFL, arg) on a pseudo-tty fails with EAGAIN,
even if arg is the result of a call to fcntl(fd, F_GETFL);

This doesn't seem right.  FWIW, same code works on Linux and 
Solaris.

Also FWIW, this is preventing us from porting our application to FreeBSD.

>How-To-Repeat:
#include <fcntl.h>
#include <stdio.h>
#include <errno.h>

main()
{
int status, fd;

    fd = open("/dev/ptyp9", 2);
    fprintf(stderr, "fd: %d\n", fd);
    errno = 0;
    status = fcntl(fd, F_GETFL);
    fprintf(stderr, "status: %d, errno: %d\n", status, errno);
    errno = 0;
    status = fcntl(fd, F_SETFL, status);
    fprintf(stderr, "status: %d, errno: %d\n", status, errno);
}
>Fix:
      
>Release-Note:
>Audit-Trail:

From: David Schultz <dschultz@uclink.Berkeley.EDU>
To: freebsd-gnats-submit@FreeBSD.org, murray@unixporting.com
Cc:  
Subject: Re: kern/36784: Can't fcntl(fd, F_SETFL, ...) on a pseudo-tty
Date: Mon, 6 May 2002 15:29:14 -0700

 I don't think you're supposed to be able to do that if the client
 isn't open, but you're right that it works on Solaris.
State-Changed-From-To: open->feedback 
State-Changed-By: jh 
State-Changed-When: Sat Mar 20 09:40:31 UTC 2010 
State-Changed-Why:  
I couldn't reproduce this on 8.0-RELEASE. Is this problem still relevant 
on recent versions of FreeBSD? 


Responsible-Changed-From-To: freebsd-bugs->jh 
Responsible-Changed-By: jh 
Responsible-Changed-When: Sat Mar 20 09:40:31 UTC 2010 
Responsible-Changed-Why:  
Track. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36784 
State-Changed-From-To: feedback->closed 
State-Changed-By: jh 
State-Changed-When: Thu Apr 29 18:24:02 UTC 2010 
State-Changed-Why:  
Feedback timeout. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=36784 
>Unformatted:
