mirror of
https://github.com/RGBCube/serenity
synced 2025-07-27 06:27:45 +00:00
LibC: Use ptsname_r() instead of ptsname() in openpty() (#7231)
This improves thread-safety because ptsname() is using a global buffer that is shared between threads.
This commit is contained in:
parent
812875bc89
commit
3ef6e31ded
1 changed files with 3 additions and 2 deletions
|
@ -34,8 +34,9 @@ int openpty(int* amaster, int* aslave, char* name, const struct termios* termp,
|
|||
return -1;
|
||||
}
|
||||
|
||||
const char* tty_name = ptsname(*amaster);
|
||||
if (!tty_name) {
|
||||
char tty_name[32];
|
||||
int rc = ptsname_r(*amaster, tty_name, sizeof(tty_name));
|
||||
if (rc < 0) {
|
||||
int error = errno;
|
||||
close(*amaster);
|
||||
errno = error;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue