Xinqi Bao's Git
5 #if !(_POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600)
15 #if defined(_GNU_SOURCE)
17 #elif _POSIX_C_SOURCE >= 200112L || _XOPEN_SOURCE >= 600
18 ptm
= posix_openpt(O_RDWR
);
20 ptm
= open("/dev/ptmx", O_RDWR
);
22 if(openpty(&ptm
, &pts
, NULL
, NULL
, NULL
) == -1)
23 eprintn("error, cannot open pty");
25 #if defined(_XOPEN_SOURCE)
27 if(grantpt(ptm
) == -1)
28 eprintn("error, cannot grant access to pty");
29 if(unlockpt(ptm
) == -1)
30 eprintn("error, cannot unlock pty");
31 ptsdev
= ptsname(ptm
);
33 eprintn("error, slave pty name undefined");
34 pts
= open(ptsdev
, O_RDWR
);
36 eprintn("error, cannot open slave pty");
39 eprintn("error, cannot open pty");