mirror of
https://github.com/RGBCube/serenity
synced 2025-07-28 08:17:34 +00:00
LibC: Add posix_openpt(), grantpt() and unlockpt()
This makes getting a pseudoterminal pair a little bit more portable. Note that grantpt() and unlockpt() are currently no-ops, since we've already granted the pseudoterminal slave to the calling user. We also accept O_CLOEXEC to posix_openpt(), unlike some systems. :^)
This commit is contained in:
parent
6d1740e4be
commit
f2a087126c
5 changed files with 58 additions and 6 deletions
|
@ -143,9 +143,19 @@ int main(int argc, char** argv)
|
|||
return;
|
||||
}
|
||||
|
||||
int ptm_fd = open("/dev/ptmx", O_RDWR);
|
||||
int ptm_fd = posix_openpt(O_RDWR);
|
||||
if (ptm_fd < 0) {
|
||||
perror("open(ptmx)");
|
||||
perror("posix_openpt");
|
||||
client_socket->close();
|
||||
return;
|
||||
}
|
||||
if (grantpt(ptm_fd) < 0) {
|
||||
perror("grantpt");
|
||||
client_socket->close();
|
||||
return;
|
||||
}
|
||||
if (unlockpt(ptm_fd) < 0) {
|
||||
perror("unlockpt");
|
||||
client_socket->close();
|
||||
return;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue