You can not select more than 25 topics
			Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
		
		
		
		
			
				
					20 lines
				
				416 B
			
		
		
			
		
	
	
					20 lines
				
				416 B
			| 
											1 year ago
										 | import ctypes
 | ||
|  | import os
 | ||
|  | 
 | ||
|  | LINUX = os.name == 'posix' and os.uname().sysname == 'Linux'
 | ||
|  | 
 | ||
|  | if LINUX:
 | ||
|  |   libc = ctypes.CDLL('libc.so.6')
 | ||
|  | 
 | ||
|  | def setthreadname(name: str) -> None:
 | ||
|  |   if LINUX:
 | ||
|  |     name = name[-15:] + '\0'
 | ||
|  |     libc.prctl(15, str.encode(name), 0, 0, 0)
 | ||
|  | 
 | ||
|  | def getthreadname() -> str:
 | ||
|  |   if LINUX:
 | ||
|  |     name = ctypes.create_string_buffer(16)
 | ||
|  |     libc.prctl(16, name)
 | ||
|  |     return name.value.decode('utf-8')
 | ||
|  |   return ""
 |