From 766cc5b2d47e0b02d839c08826a1c019024f5922 Mon Sep 17 00:00:00 2001 From: Michael Tuexen <tuexen@fh-muenster.de> Date: Wed, 15 Jun 2016 20:08:11 +0200 Subject: [PATCH] Set thread name only on FreeBSD. The thread name is only used for debugging. On Linux this breaks is_thread_sleeping(), since it assumes that the process or threadname contains no space. Just don't set this on Linux, so avoid any problems. Sponsored by Netflix --- gtests/net/packetdrill/packetdrill.c | 6 +----- gtests/net/packetdrill/run_system_call.c | 6 +----- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/gtests/net/packetdrill/packetdrill.c b/gtests/net/packetdrill/packetdrill.c index 8e03b4fd..8d726ca8 100644 --- a/gtests/net/packetdrill/packetdrill.c +++ b/gtests/net/packetdrill/packetdrill.c @@ -73,11 +73,7 @@ int main(int argc, char *argv[]) struct config config; char **arg; -#if defined(__APPLE__) - pthread_setname_np("main thread"); -#elif defined(linux) - prctl(PR_SET_NAME, "main thread"); -#elif defined(__FreeBSD__) +#if defined(__FreeBSD__) pthread_set_name_np(pthread_self(), "main thread"); #endif diff --git a/gtests/net/packetdrill/run_system_call.c b/gtests/net/packetdrill/run_system_call.c index ad3c6510..e5ee89a7 100644 --- a/gtests/net/packetdrill/run_system_call.c +++ b/gtests/net/packetdrill/run_system_call.c @@ -6269,11 +6269,7 @@ static void *system_call_thread(void *arg) struct syscall_spec *syscall = NULL; bool done = false; -#if defined(__APPLE__) - pthread_setname_np("syscall thread"); -#elif defined(linux) - prctl(PR_SET_NAME, "syscall thread"); -#elif defined(__FreeBSD__) +#if defined(__FreeBSD__) pthread_set_name_np(pthread_self(), "syscall thread"); #endif DEBUGP("syscall thread: starting and locking\n"); -- GitLab