1 /* Test of posix_openpt function.
2 Copyright (C) 2011-2012 Free Software Foundation, Inc.
4 This program is free software: you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 3 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program. If not, see <http://www.gnu.org/licenses/>. */
17 /* Written by Eric Blake <eblake@redhat.com>, 2011. */
23 #include "signature.h"
24 SIGNATURE_CHECK (posix_openpt, int, (int));
31 #if defined __sun || defined __hpux /* Solaris, HP-UX */
44 /* Open the master of a pseudo-terminal pair. */
45 master = posix_openpt (O_RDWR | O_NOCTTY);
46 if (master < 0 && errno == ENOSYS)
48 fputs ("skipping: platform lacks pty support\n", stderr);
53 name = ptsname (master);
55 ASSERT (grantpt (master) == 0);
56 ASSERT (unlockpt (master) == 0);
57 slave = open (name, O_RDWR);
60 #if defined __sun || defined __hpux /* Solaris, HP-UX */
61 ASSERT (ioctl (slave, I_PUSH, "ptem") == 0);
62 ASSERT (ioctl (slave, I_PUSH, "ldterm") == 0);
64 ASSERT (ioctl (slave, I_PUSH, "ttcompat") == 0);
68 ASSERT (isatty (slave));
70 /* Close the master side before the slave side gets closed.
71 This is necessary on MacOS X 10.4.11. */
72 ASSERT (close (master) == 0);
73 ASSERT (close (slave) == 0);