This source file includes following definitions.
- main
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19 #include <config.h>
20
21 #include <stdlib.h>
22
23 #include "signature.h"
24 SIGNATURE_CHECK (posix_openpt, int, (int));
25
26 #include <errno.h>
27 #include <fcntl.h>
28 #include <stdio.h>
29 #include <unistd.h>
30
31 #if defined __sun || defined __hpux
32 # include <stropts.h>
33 #endif
34
35 #include "macros.h"
36
37 int
38 main (void)
39 {
40 int master;
41 int slave;
42 char *name;
43
44
45 master = posix_openpt (O_RDWR | O_NOCTTY);
46 if (master < 0 && errno == ENOSYS)
47 {
48 fputs ("skipping: platform lacks pty support\n", stderr);
49 return 77;
50 }
51
52 ASSERT (0 <= master);
53 name = ptsname (master);
54 ASSERT (name);
55 ASSERT (grantpt (master) == 0);
56 ASSERT (unlockpt (master) == 0);
57 slave = open (name, O_RDWR);
58 ASSERT (0 <= slave);
59
60 #if defined __sun || defined __hpux
61 ASSERT (ioctl (slave, I_PUSH, "ptem") == 0);
62 ASSERT (ioctl (slave, I_PUSH, "ldterm") == 0);
63 # if defined __sun
64 ASSERT (ioctl (slave, I_PUSH, "ttcompat") == 0);
65 # endif
66 #endif
67
68 ASSERT (isatty (slave));
69
70
71
72 ASSERT (close (master) == 0);
73 ASSERT (close (slave) == 0);
74
75 return 0;
76 }