standards/107561: Missing SUS function tcgetsid()

Jukka Ukkonen jau at iki.fi
Fri Jan 5 03:10:10 PST 2007


>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 at 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:


More information about the freebsd-standards mailing list