diff options
author | Noah Watkins <noahwatkins@gmail.com> | 2013-07-20 18:41:39 -0700 |
---|---|---|
committer | Noah Watkins <noahwatkins@gmail.com> | 2013-09-19 15:00:31 -0700 |
commit | f3718c29bb387901f2dd520ecd75dc498fa322b7 (patch) | |
tree | 32d117b4ce7e45902a20b44fa6734cefdccf260d /src/common/code_environment.cc | |
parent | 59147be9aeea47576884e5587dd7da8bb58c6c53 (diff) | |
download | ceph-prctl-getname-test.tar.gz |
code_env: use feature test for PR_GET_NAME supportprctl-getname-test
Function `get_process_name` has platform specific dependencies. Check
for Linux prctl function and correct command flag.
Signed-off-by: Noah Watkins <noahwatkins@gmail.com>
Diffstat (limited to 'src/common/code_environment.cc')
-rw-r--r-- | src/common/code_environment.cc | 24 |
1 files changed, 15 insertions, 9 deletions
diff --git a/src/common/code_environment.cc b/src/common/code_environment.cc index 2cf19f48bc5..662fa36c9bd 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,8 @@ std::ostream &operator<<(std::ostream &oss, enum code_environment_t e) return oss; } +#if defined(HAVE_SYS_PRCTL_H) && defined(PR_GET_NAME) /* Since 2.6.11 */ + int get_process_name(char *buf, int len) { if (len <= 16) { @@ -53,17 +57,19 @@ 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 + return prctl(PR_GET_NAME, buf); } +#else + +int get_process_name(char *buf, int len) +{ + return -ENOSYS; +} + +#endif + std::string get_process_name_cpp() { char buf[32]; |