-
Notifications
You must be signed in to change notification settings - Fork 24
/
simple_threads_multi_ptrace.rs
56 lines (48 loc) · 1.43 KB
/
simple_threads_multi_ptrace.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// DebugOff
// Copyright (C) 2022 0xor0ne
//
// Licensed under:
// - GPL-3.0 when "obfuscate" feature is enabled;
// - MIT when "obfuscate" feature IS NOT enabled;
#[cfg(target_os = "linux")]
#[cfg(not(debug_assertions))]
use debugoff;
use std::thread;
use std::time::Duration;
use std::time::SystemTime;
pub fn main() {
#[cfg(target_os = "linux")]
#[cfg(not(debug_assertions))]
debugoff::multi_ptraceme_or_die();
let threads: Vec<_> = (0..10)
.map(|i| {
thread::spawn(move || {
#[cfg(target_os = "linux")]
#[cfg(not(debug_assertions))]
debugoff::multi_ptraceme_or_die();
thread::sleep(Duration::from_millis(i * 10));
#[cfg(target_os = "linux")]
#[cfg(not(debug_assertions))]
debugoff::multi_ptraceme_or_die();
println!(
"Time in thread {}: {}",
i,
SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_millis()
);
})
})
.collect();
for thread in threads.into_iter() {
thread.join().unwrap();
}
println!(
"Time in main thread: {}",
SystemTime::now()
.duration_since(SystemTime::UNIX_EPOCH)
.unwrap()
.as_millis()
);
}