From nobody@FreeBSD.org  Wed Jul 25 01:22:12 2012
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 64E2F106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 25 Jul 2012 01:22:12 +0000 (UTC)
	(envelope-from nobody@FreeBSD.org)
Received: from red.freebsd.org (red.freebsd.org [IPv6:2001:4f8:fff6::22])
	by mx1.freebsd.org (Postfix) with ESMTP id 500988FC08
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 25 Jul 2012 01:22:12 +0000 (UTC)
Received: from red.freebsd.org (localhost [127.0.0.1])
	by red.freebsd.org (8.14.4/8.14.4) with ESMTP id q6P1MC0G021516
	for <freebsd-gnats-submit@FreeBSD.org>; Wed, 25 Jul 2012 01:22:12 GMT
	(envelope-from nobody@red.freebsd.org)
Received: (from nobody@localhost)
	by red.freebsd.org (8.14.4/8.14.4/Submit) id q6P1MBBe021515;
	Wed, 25 Jul 2012 01:22:12 GMT
	(envelope-from nobody)
Message-Id: <201207250122.q6P1MBBe021515@red.freebsd.org>
Date: Wed, 25 Jul 2012 01:22:12 GMT
From: David Korn <dgk@research.att.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: tcsetgrp(fd) should fail when fd is a pipe
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         170125
>Category:       kern
>Synopsis:       [libc] tcsetpgrp(fd) should fail when fd is a pipe
>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:   Wed Jul 25 01:30:11 UTC 2012
>Closed-Date:    
>Last-Modified:  Fri Jul 27 17:33:07 UTC 2012
>Originator:     David Korn
>Release:        6.3-RELEASE-p13
>Organization:
AT&T
>Environment:
FreeBSD chud00.research.att.com 6.3-RELEASE-p13 FreeBSD 6.3-RELEASE-p13 #0: Thu Oct  1 22:30:50 UTC 2009     root@i386-builder.daemonology.net:/usr/obj/usr/src/sys/SMP i386 i386 i386 FreeBSD

>Description:
The tcgetpgrp() should fail with -1 and should set errno when the file descriptor is a pipe descriptor.  It returns 0.  Note that file descriptors created with socket pair do return -1.  The program below outputs s=0 and errno=0, but it should output s=-1 and errno non-zero.
>How-To-Repeat:
#include        <unistd.h>
#include        <stdio.h>
#include        <errno.h>
int main(int argc, char *argv[])
{
        int s,pv[2];
        pipe(pv);
        errno = 0;
        s = tcgetpgrp(pv[1]);
        fprintf(stderr,"s=%d errno=%d\n",s,errno);
        return(0);
}
>Fix:


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