2
* pty_open_ctty: Open and establish controlling terminal.
4
* Copyright 1995, 1996 by the Massachusetts Institute of Technology.
6
* Permission to use, copy, modify, and distribute this software and
7
* its documentation for any purpose and without fee is hereby
8
* granted, provided that the above copyright notice appear in all
9
* copies and that both that copyright notice and this permission
10
* notice appear in supporting documentation, and that the name of
11
* M.I.T. not be used in advertising or publicity pertaining to
12
* distribution of the software without specific, written prior
13
* permission. Furthermore if you modify this software you must label
14
* your software as modified software and not distribute it in such a
15
* fashion that it might be confused with the original M.I.T. software.
16
* M.I.T. makes no representations about the suitability
17
* of this software for any purpose. It is provided "as is" without
18
* express or implied warranty.
27
* This function will be called twice. The first time it will acquire
28
* a controlling terminal from which to vhangup() or revoke() (see
29
* comments in open_slave.c); the second time, it will be to open the
30
* actual slave device for use by the application. We no longer call
31
* ptyint_void_association(), as that will be called in
32
* pty_open_slave() to avoid spurious calls to setsid(), etc.
34
* It is assumed that systems where vhangup() exists and does break
35
* the ctty association will allow the slave to be re-acquired as the
36
* ctty. Also, if revoke() or vhangup() doesn't break the ctty
37
* association, we assume that we can successfully reopen the slave.
39
* This function doesn't check whether we actually acquired the ctty;
40
* we assume that the caller will check that, or that it doesn't
41
* matter in the particular case.
44
pty_open_ctty(const char *slave, int *fd)
49
* The Ultrix (and other BSD tty drivers) require the process
50
* group to be zero, in order to acquire the new tty as a
51
* controlling tty. This may actually belong in
52
* ptyint_void_association().
56
*fd = open(slave, O_RDWR);
58
return PTY_OPEN_SLAVE_OPENFAIL;
64
ioctl(*fd, TIOCSCTTY, 0); /* Don't check return.*/