Rollup merge of #131307 - YohDeadfall:prctl-set-name-dbg-assert, r=workingjubilee

Android: Debug assertion after setting thread name

While `prctl` cannot fail if it points to a valid buffer, it's still better to assert the result as it's done for other places.
This commit is contained in:
Matthias Krüger 2024-10-06 20:43:40 +02:00 committed by GitHub
commit 9e8c03018f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -117,13 +117,15 @@ impl Thread {
pub fn set_name(name: &CStr) {
const PR_SET_NAME: libc::c_int = 15;
unsafe {
libc::prctl(
let res = libc::prctl(
PR_SET_NAME,
name.as_ptr(),
0 as libc::c_ulong,
0 as libc::c_ulong,
0 as libc::c_ulong,
);
// We have no good way of propagating errors here, but in debug-builds let's check that this actually worked.
debug_assert_eq!(res, 0);
}
}