Austin Group Defect Tracker

Aardvark Mark IV

Viewing Issue Simple Details Jump to Notes ] Issue History ] Print ]
ID Category Severity Type Date Submitted Last Update
0000144 [1003.1(2008)/Issue 7] Base Definitions and Headers Editorial Enhancement Request 2009-09-05 17:22 2020-12-22 23:19
Reporter EdSchouten View Status public  
Assigned To ajosey
Priority normal Resolution Reopened  
Status Under Review  
Name Ed Schouten
User Reference
Section Chapter 11: TTYs
Page Number n/a
Line Number n/a
Interp Status ---
Final Accepted Text
Summary 0000144: Standard lacks a (possibly XSI) interface to associate a session to a TTY; tcsetsid()
Description According to the General Terminal Interface chapter, it is implementation defined whether a session associates to a TTY when O_NOCTTY is not passed to open():

The controlling terminal for a session is allocated by the session leader in an implementation-defined manner. If a session leader has no controlling terminal, and opens a terminal device file that is not already associated with a session without using the O_NOCTTY option (see open()), it is implementation-defined whether the terminal becomes the controlling terminal of the session leader.

Unfortunately, the standard does not specify a way to associate them when the implementation does not do this by default (i.e. the BSDs). This means it's practically impossible to implement a network login service or terminal emulator only using the interfaces described in POSIX.
Desired Action Standardizing things like TIOCSCTTY wouldn't be a good way to go. Some time ago I looked at this and it seems QNX has a solution for this that seems to be quite elegant: [^]

It's basically the counterpart of the already existing tcgetsid().

I propose adding this function to the standard, marked as XSI, where a minimal implementation only has to support the situation where the `pid' argument is equal to the session ID of the current process. This would be desirable anyway.

An implementation on operating systems that have TIOCSCTTY could then look as follows:

tcsetsid(int fd, pid_t pid)

    if (pid != getsid(0)) {
        errno = EINVAL;
        return -1;

    return ioctl(fd, TIOCSCTTY, NULL);
Tags issue8
Attached Files txt file icon tcsetsid.txt [^] (1,665 bytes) 2011-03-30 17:53
txt file icon tcsetsid_v2.txt [^] (1,871 bytes) 2011-04-03 11:14

- Relationships

-  Notes
nick (manager)
2009-09-24 15:36

The rules for introducing new material into the standard are provided in austin-112r3 ( [^]

The material introduced must have a copyright release from the original owner.

The text needs to be fully formed ... the exact words you would propose being added to the standard.

Since you have suggested that the new interface be marked XSI, the best method for moving forward would be to lobby members of The Open Group's platform working group.
EdSchouten (updater)
2010-02-21 00:00

I was just looking through my bug reports.

So what is meant with "material introduced"? Say, I come up with a specification of the function with the same prototype, would that mean I introduced the material? Or is QNX in this case the originating party?

I was just thinking, wouldn't it make more sense to add this to the base definitions, because if its high importance? Maybe tcsetsid() should also become a base definition while there.

Are there certain templates or formats which I can use? If not, should I just write a plain-text file using certain annotation?
EdSchouten (updater)
2010-02-21 00:13

Never mind "Maybe tcsetsid() should also become a base definition while there." It seems tcsetsid() is already part of the base definitions.
EdSchouten (updater)
2011-03-30 17:54

Because tcgetsid() is part of base, it would make sense to add tcsetsid() to base as well. I've attached a proposed change to the 7th edition of the standard to include tcsetsid().
msbrown (manager)
2011-03-31 15:30

Thanks for your submission! We are considering this for inclusion into the next revision (hence the tag "issue8"); we will not be considering this for an Issue 7 addendum as it is new function.

We are currently attempting to get copyright clearance for this interface. In the meantime we will be going over the text you have submitted.
EdSchouten (updater)
2011-04-03 11:15

I've corrected some small typos and also documented that tcsetsid() shall have no effect on already associated terminals.
soumendraganguly (reporter)
2020-12-22 23:19

I was wondering if alongside tcgetwinsize() and tcsetwinsize(), we could also attempt to include tcsetsid() in issue 8. Please see [^]

As EdSchouten had mentioned, tcgetsid() is already a part of the standard. FreeBSD and QNX additionally include tcsetsid().

Some implementations such as BSDs, Glibc, Solaris, ... include a library function called login_tty(), which prepares a terminal for a new login session; that procedure involves setting a controlling terminal. I am attempting to introduce a Python version of this [os.login_tty()]. Implementing this usually involves calls to setsid(), open(), close(), ttyname(), dup2(), which are currently a part of the standard; it is only when we attempt to set the controlling tty, we have to resort to using implementation-specific methods such as ioctl()+TIOCSCTTY or passing a tty file descriptor to open() without
supplying the O_NOCTTY flag. Since it is not favorable to standardize TIOCSCTTY, I request that EdSchouten's original proposal to standardize tcsetsid() be reconsidered.

- Issue History
Date Modified Username Field Change
2009-09-05 17:22 EdSchouten New Issue
2009-09-05 17:22 EdSchouten Status New => Under Review
2009-09-05 17:22 EdSchouten Assigned To => ajosey
2009-09-05 17:22 EdSchouten Name => Ed Schouten
2009-09-05 17:22 EdSchouten Section => Chapter 11: TTYs
2009-09-05 17:22 EdSchouten Page Number => n/a
2009-09-05 17:22 EdSchouten Line Number => n/a
2009-09-24 15:36 nick Note Added: 0000237
2009-09-24 15:37 msbrown Interp Status => ---
2009-09-24 15:37 msbrown Status Under Review => Resolved
2009-09-24 15:37 msbrown Resolution Open => Future Enhancement
2010-02-21 00:00 EdSchouten Note Added: 0000388
2010-02-21 00:13 EdSchouten Note Added: 0000389
2010-09-09 15:48 geoffclare Tag Attached: issue8
2011-03-30 17:53 EdSchouten File Added: tcsetsid.txt
2011-03-30 17:54 EdSchouten Note Added: 0000730
2011-03-30 17:55 EdSchouten Status Resolved => Under Review
2011-03-30 17:55 EdSchouten Resolution Future Enhancement => Reopened
2011-03-31 15:30 msbrown Note Added: 0000732
2011-04-03 11:14 EdSchouten File Added: tcsetsid_v2.txt
2011-04-03 11:15 EdSchouten Note Added: 0000736
2013-07-25 16:28 pelegri Issue Monitored: pelegri
2020-12-22 23:19 soumendraganguly Note Added: 0005188
2021-06-04 16:17 dennisw Issue Monitored: dennisw

Mantis 1.1.6[^]
Copyright © 2000 - 2008 Mantis Group
Powered by Mantis Bugtracker