Uploaded image for project: 'Jenkins'
  1. Jenkins
  2. JENKINS-71481

Job continues to run on timeout when process exits with code 0

XMLWordPrintable

      When a sh step, wrapped into a timeout step exits with code 0 when it receives a SIGTERM or SIGINTER signal, the job will continue to run and not abort.

       

      I expected that when the timeout expires, the job terminates, independent from the exit code of the process that was terminated by the timeout.
      This breaks the timeout functionality for processes that behaves badly (exit with wrong signal) or ignore the signal but terminate soon afterwards.

       

      How to reproduce:

      pipeline {
        agent any  stages {
         stage("Test") {
             steps {
             timeout(time: 3, unit: 'SECONDS') {
               script {
                 def rc = sh(
                 script: '''#!/bin/bash
                 
                 trap 'exit 0' INT TERM
                 
                 while true; do
                     echo "Sleeping..."
                     sleep 1
                 done
                 ''')
               }
             }
             echo "echo after TIMEOUT, job still running"
           }
          }
        }
      }
      

            Unassigned Unassigned
            fho Fabian Holler
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated: