Skip to main content

set_thread_name

Function set_thread_name 

Source
pub fn set_thread_name(name: &str) -> Result<(), CoreError>
Expand description

Set this thread’s name (PR_SET_NAME, the comm field visible in /proc/<pid>/task/<tid>/comm, capped at 15 bytes + NUL).

Threads created by std::thread inherit the process comm unless named, so a daemon that spawns several worker threads ends up with indistinguishable names. Naming each thread makes /proc/ps/strace output actionable (e.g. coreshift_fg vs coreshift_fps).

§Errors

  • EINVAL/EFAULT: unsupported name (truncated at 15 bytes, never a failure — this is best-effort diagnostics).