O_NOCTTY has no effect when opening /dev/tty as the open can only

succeed if there is already a controlling tty.
This commit is contained in:
Todd C. Miller
2016-05-16 11:17:20 -06:00
parent 3b39377246
commit a2e541aef8
5 changed files with 6 additions and 6 deletions

View File

@@ -1298,7 +1298,7 @@ tty_present(void)
#if defined(HAVE_STRUCT_KINFO_PROC2_P_TDEV) || defined(HAVE_STRUCT_KINFO_PROC_P_TDEV) || defined(HAVE_STRUCT_KINFO_PROC_KI_TDEV) || defined(HAVE_STRUCT_KINFO_PROC_KP_EPROC_E_TDEV) || defined(HAVE_STRUCT_PSINFO_PR_TTYDEV) || defined(HAVE_PSTAT_GETPROC) || defined(__linux__)
return user_ttypath != NULL;
#else
int fd = open(_PATH_TTY, O_RDWR|O_NOCTTY);
int fd = open(_PATH_TTY, O_RDWR);
if (fd != -1)
close(fd);
return fd != -1;