lint: replace ctermid() with ctermid_r()

This commit is contained in:
Kurtis Rader 2017-05-09 21:39:25 -07:00
parent 5659898331
commit edf745232f
2 changed files with 16 additions and 0 deletions

View file

@ -417,6 +417,17 @@ fi
# features that Autoconf doesn't tell us about # features that Autoconf doesn't tell us about
# #
dnl AC_CHECK_FUNCS uses C linkage, but sometimes (Solaris!) the behaviour is
dnl different with C++.
AC_MSG_CHECKING([if ctermid_r() available])
AC_TRY_LINK( [ #include <stdio.h> ],
[ char buf[L_ctermid]; char *foo = ctermid_r(buf); ],
[ AC_MSG_RESULT(yes)
AC_DEFINE(HAVE_CTERMID_R, 1, Define to 1 if you have the `ctermid_r' function.)
],
[AC_MSG_RESULT(no)],
)
# #
# Check if struct winsize and TIOCGWINSZ exist # Check if struct winsize and TIOCGWINSZ exist
# #

View file

@ -1520,7 +1520,12 @@ static bool check_for_orphaned_process(unsigned long loop_count, pid_t shell_pgi
if (!we_think_we_are_orphaned && loop_count % 128 == 0) { if (!we_think_we_are_orphaned && loop_count % 128 == 0) {
// Try reading from the tty; if we get EIO we are orphaned. This is sort of bad because it // Try reading from the tty; if we get EIO we are orphaned. This is sort of bad because it
// may block. // may block.
#ifdef HAVE_CTERMID_R
char buf[L_ctermid];
char *tty = ctermid_r(buf);
#else
char *tty = ctermid(NULL); char *tty = ctermid(NULL);
#endif
if (!tty) { if (!tty) {
wperror(L"ctermid"); wperror(L"ctermid");
exit_without_destructors(1); exit_without_destructors(1);