about summary refs log tree commit diff
path: root/library/std/src
diff options
context:
space:
mode:
authorMatthias Krüger <matthias.krueger@famsik.de>2024-10-06 20:43:40 +0200
committerGitHub <noreply@github.com>2024-10-06 20:43:40 +0200
commit9e8c03018fa8e8ff960fe4114239b9a976d3b306 (patch)
tree96b23adebd1dd6ac6563ff1d1fe0e8e51e6e6e56 /library/std/src
parent1e2b77d9ab92177766dc0719133be37ae8fc3ced (diff)
parent2223328d166a16cde864a17a5cb96de0853c9981 (diff)
downloadrust-9e8c03018fa8e8ff960fe4114239b9a976d3b306.tar.gz
rust-9e8c03018fa8e8ff960fe4114239b9a976d3b306.zip
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.
Diffstat (limited to 'library/std/src')
-rw-r--r--library/std/src/sys/pal/unix/thread.rs4
1 files changed, 3 insertions, 1 deletions
diff --git a/library/std/src/sys/pal/unix/thread.rs b/library/std/src/sys/pal/unix/thread.rs
index 2f2d6e6add3..04024661836 100644
--- a/library/std/src/sys/pal/unix/thread.rs
+++ b/library/std/src/sys/pal/unix/thread.rs
@@ -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);
         }
     }