Open /proc/pid/fd/[0-2] in non-blocking mode just in case we might
block in open.
This commit is contained in:
@@ -165,7 +165,7 @@ get_process_ttyname(void)
|
|||||||
ppid = getppid();
|
ppid = getppid();
|
||||||
for (i = STDIN_FILENO; i < STDERR_FILENO && tty == NULL; i++) {
|
for (i = STDIN_FILENO; i < STDERR_FILENO && tty == NULL; i++) {
|
||||||
snprintf(path, sizeof(path), "/proc/%d/fd/%d", (int)ppid, i);
|
snprintf(path, sizeof(path), "/proc/%d/fd/%d", (int)ppid, i);
|
||||||
fd = open(path, O_RDONLY|O_NOCTTY, 0);
|
fd = open(path, O_RDONLY|O_NOCTTY|O_NONBLOCK, 0);
|
||||||
if (fd != -1) {
|
if (fd != -1) {
|
||||||
tty = ttyname(fd);
|
tty = ttyname(fd);
|
||||||
close(fd);
|
close(fd);
|
||||||
|
Reference in New Issue
Block a user