Skip to content

Commit

Permalink
Fix style
Browse files Browse the repository at this point in the history
  • Loading branch information
benedikt-schesch committed May 27, 2024
1 parent b915f87 commit d3a848b
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/scripts/run_with_timeout.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
#!/bin/bash
# usage: ./run_with_timeout.sh <timeout_in_seconds> <command>
# Run a command with a timeout. The exit status is 0 for success, 124 for timeout, and 1 for failure.

# Check if the correct number of arguments was provided
if [ "$#" -ne 2 ]; then
Expand All @@ -9,14 +11,12 @@ fi
# Read the timeout and command from arguments
TIMEOUT=$1
shift
COMMAND=$@
COMMAND=$*

# Function to run the command with a timeout
run_command_with_timeout() {
# Using the timeout command to manage the execution time
# '--foreground' allows it to kill the process group of a foreground job
# '--kill-after' ensures the process group is killed if it doesn't exit within a grace period after the timeout
timeout --kill-after=10 $TIMEOUT $COMMAND
# shellcheck disable=SC2086
timeout --kill-after=10 "$TIMEOUT" $COMMAND
local STATUS=$?

# Check if the command timed out
Expand Down

0 comments on commit d3a848b

Please sign in to comment.