]>
git.proxmox.com Git - mirror_lxc.git/blob - src/include/openpty.c
2 * openpty: glibc implementation
4 * Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
7 * Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
24 #define _XOPEN_SOURCE /* See feature_test_macros(7) */
32 #include <sys/types.h>
33 #include <sys/ioctl.h>
35 #define _PATH_DEVPTMX "/dev/ptmx"
37 int openpty (int *amaster
, int *aslave
, char *name
, struct termios
*termp
,
43 master
= open(_PATH_DEVPTMX
, O_RDWR
);
53 if (ptsname_r(master
, buf
, sizeof buf
))
56 slave
= open(buf
, O_RDWR
| O_NOCTTY
);
60 /* XXX Should we ignore errors here? */
62 tcsetattr(slave
, TCSAFLUSH
, termp
);
64 ioctl(slave
, TIOCSWINSZ
, winp
);