File tree Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Expand file tree Collapse file tree 1 file changed +17
-0
lines changed Original file line number Diff line number Diff line change @@ -65,6 +65,22 @@ fn main() {
6565 }
6666 }
6767
68+ // Set name via Rust API, get it via pthreads.
69+ let long_name2 = long_name. clone ( ) ;
70+ thread:: Builder :: new ( )
71+ . name ( long_name. clone ( ) )
72+ . spawn ( move || {
73+ let mut buf = vec ! [ 0u8 ; long_name2. len( ) + 1 ] ;
74+ assert_eq ! ( get_thread_name( & mut buf) , 0 ) ;
75+ let cstr = CStr :: from_bytes_until_nul ( & buf) . unwrap ( ) ;
76+ let truncated_name = & long_name2[ ..long_name2. len ( ) . min ( MAX_THREAD_NAME_LEN - 1 ) ] ;
77+ assert_eq ! ( cstr. to_bytes( ) , truncated_name. as_bytes( ) ) ;
78+ } )
79+ . unwrap ( )
80+ . join ( )
81+ . unwrap ( ) ;
82+
83+ // Set name via pthread and get it again (short name).
6884 thread:: Builder :: new ( )
6985 . spawn ( move || {
7086 // Set short thread name.
@@ -130,6 +146,7 @@ fn main() {
130146 . join ( )
131147 . unwrap ( ) ;
132148
149+ // Set name via pthread and get it again (long name).
133150 thread:: Builder :: new ( )
134151 . spawn ( move || {
135152 // Set full thread name.
You can’t perform that action at this time.
0 commit comments