Skip to content

Commit 0021cb6

Browse files
committed
Thread: Dont trim thread name on Linux
1 parent ba6bc4b commit 0021cb6

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

CoreFoundation/Base.subproj/CFPlatform.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1323,11 +1323,7 @@ CF_SWIFT_EXPORT int _CFThreadSetName(pthread_t thread, const char *_Nonnull name
13231323
}
13241324
return EINVAL;
13251325
#elif DEPLOYMENT_TARGET_LINUX
1326-
// pthread_setname_np will fail if name >= 16 characters
1327-
char short_name[16];
1328-
strncpy(short_name, name, 15);
1329-
short_name[15] = '\0';
1330-
return pthread_setname_np(thread, short_name);
1326+
return pthread_setname_np(thread, name);
13311327
#endif
13321328
}
13331329

TestFoundation/TestThread.swift

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,9 @@ class TestThread : XCTestCase {
103103
#if os(OSX) || os(iOS)
104104
compareThreadName(to: "12345678901234567890")
105105
#elseif os(Linux)
106-
// pthread_setname_np() only allows 15 characters on Linux
107-
compareThreadName(to: "123456789012345")
106+
// pthread_setname_np() only allows 15 characters on Linux, so setting it fails
107+
// and the previous name will still be there.
108+
compareThreadName(to: "Thread2-2")
108109
#endif
109110
condition.lock()
110111
condition.signal()

0 commit comments

Comments
 (0)