-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathwarm
More file actions
executable file
·44 lines (33 loc) · 680 Bytes
/
Copy pathwarm
File metadata and controls
executable file
·44 lines (33 loc) · 680 Bytes
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
#!/usr/bin/env bash
default_max_time=200 # seconds
cleanup() {
# Kill any child processes
pkill -P $$
exit 0
}
cpu_num=$(nproc)
max_time=$1
if [ $# -ne 1 ]; then
max_time=$default_max_time
fi
echo "Using $cpu_num CPUs for $max_time seconds"
# Register the cleanup function to run on SIGINT and SIGTERM signals
trap cleanup SIGINT SIGTERM
function loop() {
while true; do
# shellcheck disable=SC2034
j=1
done
}
# Start the timer in the background
(
set -e
sleep "$max_time"
echo "Time limit reached ($max_time seconds). Cleaning up..."
cleanup >/dev/null
) &
for i in $(seq "$cpu_num"); do
loop "$i" &
done
# Wait for child processes to complete
wait