Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Thread::spawn does not lead to clone() syscall?
I was readng through Using Threads to Run Code Simultaneously - The Rust Programming Language and tried the sample code there.
I compiled the code with rustc main.rs
and then tried to trace the clone() syscall using the command:
strace -f -e clone,fork,execve,futex ./main.elf
However, to my surprise, there was no clone() syscall as shown in the output below:
strace: Process 686239 attached
hi number 1 from the main thread!
hi number 1 from the spawned thread!
hi number 2 from the main thread!
hi number 2 from the spawned thread!
hi number 3 from the main thread!
hi number 3 from the spawned thread!
hi number 4 from the main thread!
hi number 4 from the spawned thread!
[pid 686239] +++ exited with 0 +++
+++ exited with 0 +++
I ran it multiple times, but never observed clone() syscall in the strace output. Shouldn't thread::spawn
in that code lead to clone() syscall on my Ubuntu 24.04 system? System details below:
bash$ lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description: Ubuntu 24.04.2 LTS
Release: 24.04
Codename: noble
bash$ uname -r
6.11.0-25-generic
bash$ uname -m
x86_64
6 posts - 4 participants
🏷️ rust_feed