18.2.1 Runner stuck running and exceed timeout using shell executor
## Summary <!-- Briefly summarize the bug --> Based on our documentation we should be able to control the timeout for jobs at different levels like: - [Runner timeout](https://docs.gitlab.com/ci/runners/configure_runners/#set-the-maximum-job-timeout) - [Project timeout](https://docs.gitlab.com/ci/pipelines/settings/#set-a-limit-for-how-long-jobs-can-run) - [Job timeout](https://docs.gitlab.com/ci/yaml/#timeout) If a job reaches the timeout, it is expected to fail however in this case it's stuck in `Running` state and will only fail after the job process completes (e.g. long running task, sleep, etc). This might be a potential regression of this issue: - [Gracefully stop long running processes when using the shell executor - Take 2](https://gitlab.com/gitlab-org/gitlab-runner/-/merge_requests/4896) ## Steps to reproduce <!-- What do you need to do to reproduce the bug? Please include job definitions or git repository structure if relevant --> 1. Create a new project with the following `.gitlab-ci.yml`. 2. Setup a GitLab Runner 18.2.1 and assign to this project. 3. Set a project timeout of 10 minutes (this is the minimum for project level). 4. Set a job timeout of 60 seconds. 5. Run the job. 6. Wait for 60 seconds and observe this error in the job log. ``` Session terminated, killing shell... ...killed. ``` 6. Observe that the job continues to run. 7. Wait for 300 seconds and observe the job changes to `failed` state. <!-- Please add the definition of the job from `.gitlab-ci.yml` that is failing inside of the code blocks (```) below. --> <details> <summary> .gitlab-ci.yml </summary> ```yml stages: - test sleep_job: stage: test timeout: 60s script: - echo "StartJob:" $(date) - echo "PID $$" - sleep 300 after_script: - echo "EndJob:" $(date) ``` </details> ## Actual behavior <!-- What actually happens --> - Job continues to run after the job level timeout of 60 seconds and only fails after 300 seconds. ## Expected behavior <!-- What you should see instead --> - Job should fail immediately after 60 seconds. ## Relevant logs and/or screenshots ![Screenshot_2025-10-01+at+3.28.31_PM](/uploads/8c836e477964b2da9cd3451993521c9e/Screenshot_2025-10-01+at+3.28.31_PM.png) ![Screenshot_2025-10-01+at+3.29.19_PM](/uploads/9d9bf854fa6fbc21a38a8680694e4fe2/Screenshot_2025-10-01+at+3.29.19_PM.png) <!-- Paste the job logs inside of the code blocks (```) below so it would be easier to read. --> <details> <summary> job log </summary> ```sh Add the job log ``` </details> ## Environment description GitLab 18.2.1 <!-- Are you using shared Runners on GitLab.com? Or is it a custom installation? Which executors are used? Please also provide the versions of related tools like `docker info` if you are using the Docker executor. --> <!-- Please add the contents of `config.toml` inside of the code blocks (```) below, remember to remove any secret tokens! --> <details> <summary> config.toml contents </summary> ```toml concurrent = 1 check_interval = 0 connection_max_age = "15m0s" shutdown_timeout = 0 [session_server] session_timeout = 1800 [[runners]] name = "runner-instance" url = "http://gitlab.docker.dev" id = 1 token = "XXXX" token_obtained_at = 2025-10-01T07:25:09Z token_expires_at = 0001-01-01T00:00:00Z executor = "shell" [runners.cache] MaxUploadedArchiveSize = 0 [runners.cache.s3] [runners.cache.gcs] [runners.cache.azure] ``` </details> ### Used GitLab Runner version GitLab Runner 18.2.1 <!-- Please run and paste the output of `gitlab-runner --version`. If you are using a Runner where you don't have access to, please paste at least the first lines the from build log, like: ``` Running with gitlab-ci-multi-runner 1.4.2 (bcc1794) Using Docker executor with image golang:1.8 ... ``` --> ## Possible fixes <!-- (If you can, link to the line of code that might be responsible for the problem) --->
issue