From nobody@FreeBSD.org  Thu Dec  3 22:42:06 2009
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id BC6AA1065676
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  3 Dec 2009 22:42:06 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21])
	by mx1.freebsd.org (Postfix) with ESMTP id AA5868FC1B
	for <freebsd-gnats-submit@FreeBSD.org>; Thu,  3 Dec 2009 22:42:06 +0000 (UTC)
Received: from www.freebsd.org (localhost [127.0.0.1])
	by www.freebsd.org (8.14.3/8.14.3) with ESMTP id nB3Mg6Vh013892
	for <freebsd-gnats-submit@FreeBSD.org>; Thu, 3 Dec 2009 22:42:06 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id nB3Mg6RN013891;
	Thu, 3 Dec 2009 22:42:06 GMT
	(envelope-from nobody)
Message-Id: <200912032242.nB3Mg6RN013891@www.freebsd.org>
Date: Thu, 3 Dec 2009 22:42:06 GMT
From: john hood <jh@sandstorm.net>, sandstorm-ni@sandstorm.net
To: freebsd-gnats-submit@FreeBSD.org
Subject: TIOCDRAIN ioctl on pts/pty master hangs
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         141150
>Category:       kern
>Synopsis:       [pty] [hang] TIOCDRAIN ioctl on pts/pty master hangs
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Thu Dec 03 22:50:01 UTC 2009
>Closed-Date:    
>Last-Modified:  Fri Dec 04 00:05:46 UTC 2009
>Originator:     john hood
>Release:        8.0-RELEASE
>Organization:
Sandstorm Enterprises
>Environment:
FreeBSD lister.sandstorm.net 8.0-RELEASE FreeBSD 8.0-RELEASE #0: Tue Dec  1 20:49:34 EST 2009     jh@lister.sandstorm.net:/usr/src/sys/amd64/compile/NOCD  amd64

>Description:
our ancient 'gksu' port is broken-- it hangs after running the su/sudo command, and so output from the command never appears and gksu never exits.

the problem is twofold-- a bug in libgksu, which calls tcdrain() on the master side of a pty; and a bug in kernel, which hangs rather than returning an error on the tty ioctl.

see ports/141149 for a report + patch on libgksu.

I observe this on both 7.1 and 8.0.

8.0 kernel sleeps on ttyout when this happens.

In 8.0, ptsdev_ioctl() already seems to have some code to handle just this case, but it's only applied to the TIOCSETA[FW] ioctls used by tcsetattr().  So maybe it just needs to do this for TIOCFLUSH/TIOCDRAIN too.

In 7.1, something different happens, of course-- it looks like all these cases go through to the slave pty, and just TIOCSETA[FW] get a flush beforehand.


>How-To-Repeat:
sudo pkg_add -r gksu
gdb gksu id
^C

>Fix:


>Release-Note:
>Audit-Trail:
>Unformatted:
