public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Omair Majid <omajid@redhat.com>
To: git-commits@fedoraproject.org
Subject: [rpms/dotnet8.0] main: Reduce time to detect hanging builds
Date: Fri, 24 Jul 2026 16:44:54 GMT	[thread overview]
Message-ID: <178491149401.1.2372047043132147137.rpms-dotnet8.0-a0ae897c20e5@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/dotnet8.0
            Branch : main
            Commit : a0ae897c20e5087d55aa819a091b890add482b36
            Author : Omair Majid <omajid@redhat.com>
            Date   : 2026-07-24T12:44:22-04:00
            Stats  : +61/-2 in 1 file(s)
            URL    : https://src.fedoraproject.org/rpms/dotnet8.0/c/a0ae897c20e5087d55aa819a091b890add482b36?branch=main

            Log:
            Reduce time to detect hanging builds

Fail the build if it produces no output for a while, instead of a
hardcoded entire-build timeout of 5 hours.

Co-Authored-By: Tom Deseyn <tdeseyn@redhat.com>

---
diff --git a/dotnet8.0.spec b/dotnet8.0.spec
index 6cc8fa3..03b0b6a 100644
--- a/dotnet8.0.spec
+++ b/dotnet8.0.spec
@@ -576,8 +576,67 @@ function retry_until_success {
     return $exit_code
 }
 
+# Runs a command and kills it if it produces no output.
+# Use a longer timeout on machines with fewer cores since builds are slower.
+function output_timeout {
+    # 30m on machines with more than 4 cores, 60m on smaller machines where builds are slower.
+    # The aarch64 Neoverse N1 CI machines have 4 cores and need the longer timeout.
+    local nprocs=$(nproc)
+    local idle_timeout=1800
+    if (( nprocs <= 4 )); then
+        idle_timeout=3600
+    fi
+
+    # Create a pipe we'll read the output from for timeout detection.
+    local fifo=$(mktemp -u)
+    mkfifo "$fifo"
+
+    # Create a process group so we can kill every process including children.
+    # And use a long timeout (5h) in (the unlikely) case output timeout detection continues to be triggered.
+    setsid timeout --foreground 5h "$@" &> "$fifo" &
+    local cmd_pid=$!
+
+    # Read lines from the output with a timeout.
+    # Disable tracing to avoid 'set -x' noise from the read loop appearing in the output.
+    local timed_out=false
+    local traceflags=$-
+    set +x
+    while true; do
+        local rc=0
+        IFS= read -t $idle_timeout -r line || rc=$?
+        if (( rc == 0 )); then
+            printf '%s\n' "$line"
+        elif (( rc > 128 )); then
+            echo "output_timeout: no output for ${idle_timeout}s" >&2
+            timed_out=true
+            break
+        else
+            [[ -z $line ]] || printf '%s\n' "$line"
+            break
+        fi
+    done < "$fifo"
+    [[ $traceflags != *x* ]] || set -x
+
+    if $timed_out; then
+        # Hang detected: kill the process group, then collect the exit code.
+        kill -9 -- -$cmd_pid 2>/dev/null || true
+        wait $cmd_pid 2>/dev/null
+        local exit_code=$?
+    else
+        # Normal exit: collect the real exit code, then clean up any orphaned processes.
+        wait $cmd_pid 2>/dev/null
+        local exit_code=$?
+        kill -9 -- -$cmd_pid 2>/dev/null || true
+    fi
+
+    # Cleanup.
+    rm -f "$fifo"
+
+    return $exit_code
+}
+
 VERBOSE=1 retry_until_success $max_attempts \
-    timeout 5h \
+    output_timeout \
     ./build.sh \
 %if %{without bootstrap}
     --with-sdk previously-built-dotnet \
@@ -785,7 +844,7 @@ export COMPlus_LTTng=0
 
 
 %changelog
-* Tue Jul 20 2026 Omair Majid <omajid@redhat.com> - 8.0.129-1
+* Mon Jul 20 2026 Omair Majid <omajid@redhat.com> - 8.0.129-1
 - Update to .NET SDK 8.0.129 and Runtime 8.0.29
 
 * Wed Jul 15 2026 Fedora Release Engineering <releng@fedoraproject.org> - 8.0.128-2

                 reply	other threads:[~2026-07-24 16:44 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=178491149401.1.2372047043132147137.rpms-dotnet8.0-a0ae897c20e5@fedoraproject.org \
    --to=omajid@redhat.com \
    --cc=git-commits@fedoraproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox