Open /proc/pid/fd/[0-2] in non-blocking mode just in case we might

block in open.
This commit is contained in:
Todd C. Miller
2012-04-10 09:26:52 -04:00
parent 53357633f1
commit 30fee3aade

View File

@@ -165,7 +165,7 @@ get_process_ttyname(void)
ppid = getppid();
for (i = STDIN_FILENO; i < STDERR_FILENO && tty == NULL; 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) {
tty = ttyname(fd);
close(fd);