1
0
mirror of https://github.com/php/php-src.git synced 2026-03-31 04:32:19 +02:00

Refix posix_ttyname(), test for a working implementation of ttyname_r() -- which BSD doesn't have

This commit is contained in:
Sara Golemon
2007-01-05 21:30:06 +00:00
parent 925cbe4cfe
commit b42c175d75
2 changed files with 18 additions and 6 deletions

View File

@@ -11,5 +11,22 @@ if test "$PHP_POSIX" = "yes"; then
AC_CHECK_HEADERS(sys/mkdev.h)
AC_CHECK_FUNCS(seteuid setegid setsid getsid setpgid getpgid ctermid mkfifo mknod getrlimit getlogin getgroups makedev initgroups getpwuid_r getgrgid_r ttyname_r)
AC_CHECK_FUNCS(seteuid setegid setsid getsid setpgid getpgid ctermid mkfifo mknod getrlimit getlogin getgroups makedev initgroups getpwuid_r getgrgid_r)
AC_MSG_CHECKING([for working ttyname_r() implementation])
AC_TRY_RUN([
#include <unistd.h>
int main(int argc, char *argv[])
{
char buf[64];
return ttyname_r(0, buf, 64) ? 1 : 0;
}
],[
AC_MSG_RESULT([yes])
AC_DEFINE(HAVE_TTYNAME_R, 1, [Whether you have a working ttyname_r])
],[
AC_MSG_RESULT([no, posix_ttyname() will be thread-unsafe])
])
fi

View File

@@ -575,12 +575,7 @@ PHP_FUNCTION(posix_ttyname)
fd = Z_LVAL_PP(z_fd);
}
#if HAVE_TTYNAME_R
#ifdef _SC_TTY_NAME_MAX
buflen = sysconf(_SC_TTY_NAME_MAX);
#else
/* Arbitrary buffer size for systems which don't extrospect their tty name lengths, way overkill */
buflen = 64;
#endif
p = emalloc(buflen);
if (ttyname_r(fd, p, buflen)) {