1 diff -N -u -r ../socat-1.7.2.4/openpty.c ./openpty.c
2 --- ../socat-1.7.2.4/openpty.c 1970-01-01 01:00:00.000000000 +0100
3 +++ ./openpty.c 2014-07-15 15:23:08.731170078 +0200
5 +/* Copyright (C) 1998, 1999, 2004 Free Software Foundation, Inc.
6 + This file is part of the GNU C Library.
7 + Contributed by Zack Weinberg <zack@rabi.phys.columbia.edu>, 1998.
9 + The GNU C 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 + The GNU C 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 the GNU C Library; if not, write to the Free
21 + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
31 +#include <sys/types.h>
32 +#include <sys/ioctl.h>
34 +#define _PATH_DEVPTMX "/dev/ptmx"
36 +int openpty (int *amaster, int *aslave, char *name, struct termios *termp,
37 + struct winsize *winp)
42 + master = open(_PATH_DEVPTMX, O_RDWR);
46 + if (grantpt(master))
49 + if (unlockpt(master))
52 + if (ptsname_r(master, buf, sizeof buf))
55 + slave = open(buf, O_RDWR | O_NOCTTY);
59 + /* XXX Should we ignore errors here? */
61 + tcsetattr(slave, TCSAFLUSH, termp);
63 + ioctl(slave, TIOCSWINSZ, winp);