I don't have a FreeBSD box so not sure if this works but... Here you are a proposed fix: --- configure.ac | 16 ++++++++++++++++ process.c | 17 ++++++++++++++++- 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/configure.ac b/configure.ac index 71e71dd47a..f96606494f 100644 --- a/configure.ac +++ b/configure.ac @@ -2618,6 +2618,22 @@ main(int argc, char *argv[]) rb_cv_fork_with_pthread=yes)]) test x$rb_cv_fork_with_pthread = xyes || AC_DEFINE(CANNOT_FORK_WITH_PTHREAD) ]) + +AS_IF([test "$ac_cv_func_getlogin_r" = "yes"], [ + AC_CACHE_CHECK([if getlogin_r is POSIX compliant], rb_cv_getlogin_r_is_posix, [ + RUBY_WERROR_FLAG([ + AC_TRY_COMPILE([ +@%:@include <unistd.h> +static int (*conftest)(char *, size_t) = getlogin_r; + ], [], + [rb_cv_getlogin_r_is_posix=yes], + [rb_cv_getlogin_r_is_posix=no]) + ]) + ]) + AS_IF([test "$rb_cv_getlogin_r_is_posix" = yes], [ + AC_DEFINE(HAVE_POSIX_COMPLIANT_GETLOGIN_R) + ]) +]) } : "runtime section" && { diff --git a/process.c b/process.c index e8a786d55e..9ccf8a2db4 100644 --- a/process.c +++ b/process.c @@ -5560,6 +5560,21 @@ check_gid_switch(void) #if defined(HAVE_PWD_H) +#if HAVE_GETLOING_R +static inline int +wrap_getlogin_r(char *ptr, long passed_len) +{ +#ifdef HAVE_POSIX_COMPLIANT_GETLOGIN_R + size_t len = passed_len; +#else + int len = rb_long2int(len); +#endif + + RUBY_ASSERT(passed_len >= 0); + return getlogin_r(ptr, len); +} +#endif + /** * Best-effort attempt to obtain the name of the login user, if any, * associated with the process. Processes not descended from login(1) (or @@ -5588,7 +5603,7 @@ rb_getlogin(void) int gle; errno = 0; - while ((gle = getlogin_r(login, loginsize)) != 0) { + while ((gle = wrap_getlogin_r(login, loginsize)) != 0) { if (gle == ENOTTY || gle == ENXIO || gle == ENOENT) { rb_str_resize(maybe_result, 0); -- 2.17.1 Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe> <http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>