jenkinsci / jenkinsci/durable-task-plugin

[JENKINS-71481] Job continues to run on timeout when process exits with code 0

Open
#502 2 comments 0 reactions 0 assignees View on GitHub
component:durable-task-plugin component:workflow-durable-task-step-plugin imported-jira-issue priority:minor resolution:unresolved
Dominant language
Java
Stars
30
Forks
101
PR merge metrics
No merged PRs in 30d

Description

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"
     }
    }
  }
}

---
Originally reported by fho, imported from: Job continues to run on timeout when process exits with code 0


  • status: Open
  • priority: Minor
  • component(s): durable-task-plugin, workflow-durable-task-step-plugin
  • resolution: Unresolved
  • votes: 0
  • watchers: 2
  • imported: 2025-12-09

Raw content of original issue

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"
     }
    }
  }
}

environment

```
Jenkins 2.401.1

Pipeline Basic Steps 1017.vb_45b_302f0cea_
```

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.