Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 20 additions & 4 deletions afl-cov
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -865,7 +865,7 @@ def run_cmd(
collect: int,
aflrun: bool,
fn: str,
timeout: Optional[int] = None,
timeout: Optional[str] = None,
) -> Tuple[int, List[bytes]]:
out = []

Expand All @@ -886,9 +886,25 @@ def run_cmd(
else:
print(" CMD: %s" % cmd)

exit_code = subprocess.call(
cmd, stdin=None, stdout=fh, stderr=subprocess.STDOUT, shell=True
)
if timeout:
cmd = "timeout -s KILL %s %s" % (timeout, cmd)

# If timeout is in seconds, add an extra layer of timeout
# the timeout linux command failed me on several occasions
sp_timeout = int(timeout) * 2 if timeout and timeout.isdigit() else None

try:
exit_code = subprocess.call(
cmd, stdin=None, stdout=fh, stderr=subprocess.STDOUT, shell=True,
timeout=sp_timeout
)
except subprocess.TimeoutExpired:
if cargs.verbose:
if log_file:
logr(b" CMD: %s timedout: %s" % (cmd.encode(), str(ex)), log_file, cargs)
else:
print(" CMD: %s timedout: %s" % (cmd, str(ex)))
exit_code = -1

fh.close()

Expand Down