sys/sysinfo.h
coff.h pty.h
sys/resource.h
- sys/utsname.h pwd.h utmp.h util.h sys/prctl.h)
+ sys/utsname.h pwd.h utmp.h util.h)
AC_CACHE_CHECK([for ADDR_NO_RANDOMIZE],
[emacs_cv_personality_addr_no_randomize],
sendto recvfrom getsockname getifaddrs freeifaddrs \
gai_strerror sync \
getpwent endpwent getgrent endgrent \
-cfmakeraw cfsetspeed __executable_start log2 prctl)
+cfmakeraw cfsetspeed __executable_start log2 pthread_setname_np)
LIBS=$OLD_LIBS
dnl No need to check for posix_memalign if aligned_alloc works.
#include <sched.h>
-#ifdef HAVE_SYS_PRCTL_H
-#include <sys/prctl.h>
-#endif
-
void
sys_mutex_init (sys_mutex_t *mutex)
{
if (!pthread_attr_setdetachstate (&attr, PTHREAD_CREATE_DETACHED))
{
result = pthread_create (thread_ptr, &attr, func, arg) == 0;
-#if defined (HAVE_SYS_PRCTL_H) && defined (HAVE_PRCTL) && defined (PR_SET_NAME)
+#ifdef HAVE_PTHREAD_SETNAME_NP
if (result && name != NULL)
- prctl (PR_SET_NAME, name);
+ {
+ /* We need to truncate here otherwise pthread_setname_np
+ fails to set the name. TASK_COMM_LEN is what the length
+ is called in the Linux kernel headers (Bug#38632). */
+#define TASK_COMM_LEN 16
+ char p_name[TASK_COMM_LEN];
+ strncpy (p_name, name, TASK_COMM_LEN - 1);
+ p_name[TASK_COMM_LEN - 1] = '\0';
+ pthread_setname_np (*thread_ptr, p_name);
+ }
#endif
}
new_thread->next_thread = all_threads;
all_threads = new_thread;
- char const *c_name = !NILP (name) ? SSDATA (ENCODE_UTF_8 (name)) : NULL;
+ char const *c_name = !NILP (name) ? SSDATA (ENCODE_SYSTEM (name)) : NULL;
if (c_name)
new_thread->thread_name = xstrdup (c_name);
else