diff options
author | Noah Watkins <noahwatkins@gmail.com> | 2013-07-20 18:41:39 -0700 |
---|---|---|
committer | Noah Watkins <noahwatkins@gmail.com> | 2013-07-20 18:41:39 -0700 |
commit | 1ef6fd1c5847ed5c57376e62797080993b6f8bf8 (patch) | |
tree | 1a3b453ebb6e852a94d1dda42ee9ad6e83071abd | |
parent | f18ca2c526585a2f25d31d6c3129364e57631fa3 (diff) | |
download | ceph-1ef6fd1c5847ed5c57376e62797080993b6f8bf8.tar.gz |
code_env: do not use prctl on non-linux
get_process_name is platform specific. Check for Linux prctl function and
headers, and add reference to the relevant OSX function.
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
-rw-r--r-- | configure.ac | 3 | ||||
-rw-r--r-- | src/common/code_environment.cc | 21 |
2 files changed, 18 insertions, 6 deletions
diff --git a/configure.ac b/configure.ac index d2be11ebfa8..e94d4868d83 100644 --- a/configure.ac +++ b/configure.ac @@ -537,6 +537,9 @@ AC_CHECK_MEMBER([struct stat.st_mtimespec.tv_nsec], [AC_DEFINE(HAVE_STAT_ST_TIMESPEC, 1, [Define if you have struct stat.st_mtimespec.tv_nsec])]) +AC_CHECK_HEADERS([sys/prctl.h]) +AC_CHECK_FUNCS([prctl]) + # Checks for typedefs, structures, and compiler characteristics. #AC_HEADER_STDBOOL #AC_C_CONST diff --git a/src/common/code_environment.cc b/src/common/code_environment.cc index 2cf19f48bc5..b5c8fe7a2a6 100644 --- a/src/common/code_environment.cc +++ b/src/common/code_environment.cc @@ -11,6 +11,7 @@ * Foundation. See file COPYING. * */ +#include <acconfig.h> #include "common/code_environment.h" @@ -19,7 +20,8 @@ #include <stdlib.h> #include <string.h> #include <string> -#if defined(__linux__) + +#ifdef HAVE_SYS_PRCTL_H #include <sys/prctl.h> #endif @@ -45,6 +47,7 @@ std::ostream &operator<<(std::ostream &oss, enum code_environment_t e) return oss; } +#ifdef __linux__ int get_process_name(char *buf, int len) { if (len <= 16) { @@ -53,16 +56,22 @@ int get_process_name(char *buf, int len) * null-terminated. */ return -ENAMETOOLONG; } -#if defined(__FreeBSD__) -#warning XXX - return -ENAMETOOLONG; -#else + memset(buf, 0, len); int ret; ret = prctl(PR_GET_NAME, buf); return ret; -#endif } +#else +int get_process_name(char *buf, int len) +{ + /* + * OSX: + * - include/libproc.h: proc_name() + */ + return -ENAMETOOLONG; +} +#endif std::string get_process_name_cpp() { |