Xinqi Bao's Git
3efaa7f480f649d453f6e8506982c5bcad083de0
1 /* See LICENSE file for copyright and license details. */
6 #if !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
16 #if defined(_GNU_SOURCE)
18 #elif _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
19 ptm
= posix_openpt(O_RDWR
);
21 ptm
= open("/dev/ptmx", O_RDWR
);
23 if(openpty(&ptm
, &pts
, NULL
, NULL
, NULL
) == -1)
24 err(EXIT_FAILURE
, "cannot open pty");
26 #if defined(_XOPEN_SOURCE)
28 if(grantpt(ptm
) == -1)
29 err(EXIT_FAILURE
, "cannot grant access to pty");
30 if(unlockpt(ptm
) == -1)
31 err(EXIT_FAILURE
, "cannot unlock pty");
32 ptsdev
= ptsname(ptm
);
34 err(EXIT_FAILURE
, "slave pty name undefined");
35 pts
= open(ptsdev
, O_RDWR
);
37 err(EXIT_FAILURE
, "cannot open slave pty");
40 err(EXIT_FAILURE
, "cannot open pty");