Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 5 Jan 2007 11:08:35 GMT
From:      Jukka Ukkonen<jau@iki.fi>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   standards/107561: Missing SUS function tcgetsid()
Message-ID:  <200701051108.l05B8Zl8008051@www.freebsd.org>
Resent-Message-ID: <200701051110.l05BA9B9072558@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         107561
>Category:       standards
>Synopsis:       Missing SUS function tcgetsid()
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-standards
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 05 11:10:09 GMT 2007
>Closed-Date:
>Last-Modified:
>Originator:     Jukka Ukkonen
>Release:        FreeBSD 6.2-PRERELEASE
>Organization:
private individual, not representing any organization
>Environment:
FreeBSD mjolnir 6.2-PRERELEASE FreeBSD 6.2-PRERELEASE #1: Fri Jan  5 09:43:02 EET 2007     root@mjolnir:/usr/obj/usr/src/sys/Mjolnir  i386
>Description:
The SUS function tcgetsid() seems to be missing in FreeBSD.

This is SUS compatibility only.
This was not strictly required by POSIX at the time it was implemented
for SUS, but since SUS clearly is a major driver in the POSIX activities,
tcgetsid() might be an obvious future extension to POSIX anyhow.
And furthermore there is no sane reason for sticking to POSIX only,
if the extension needed to become better compatible with other major
specifications happens to be this easy.

>How-To-Repeat:
No actual problem.
The function tcgetsid() is a convenience function and
it can always be replaced by ...
getsid (tcgetpgrp (fd))

>Fix:

#include <sys/types.h>
#include <sys/ioctl.h>
#include <unistd.h>
#include <termios.h>

pid_t
tcgetsid (fd)
    int     fd;
{
    int     pgrp;

    if (ioctl (fd, TIOCGPGRP, &pgrp) < 0)
        return ((pid_t) -1);

    return (getsid((pid_t) pgrp));
}

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



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200701051108.l05B8Zl8008051>