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>
[])
+AC_CHECK_HEADERS([sys/prctl.h])
+AC_CHECK_FUNCS([prctl])
+
# Checks for typedefs, structures, and compiler characteristics.
#AC_HEADER_STDBOOL
#AC_C_CONST
* Foundation. See file COPYING.
*
*/
+#include "acconfig.h"
#include "common/code_environment.h"
#include <stdlib.h>
#include <string.h>
#include <string>
-#if defined(__linux__)
+
+#ifdef HAVE_SYS_PRCTL_H
#include <sys/prctl.h>
#endif
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) {
* 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];