1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 15:17:36 +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:
Andreas Kling 2020-02-05 21:17:41 +01:00
parent 6d1740e4be
commit f2a087126c
5 changed files with 58 additions and 6 deletions

View file

@ -746,4 +746,26 @@ char* realpath(const char* pathname, char* buffer)
errno = 0;
return buffer;
}
int posix_openpt(int flags)
{
if (flags & ~(O_RDWR | O_NOCTTY | O_CLOEXEC)) {
errno = EINVAL;
return -1;
}
return open("/dev/ptmx", flags);
}
int grantpt(int fd)
{
(void)fd;
return 0;
}
int unlockpt(int fd)
{
(void)fd;
return 0;
}
}