fg in zsh sometimes fails to restore stopped job
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
zsh (Ubuntu) |
New
|
Undecided
|
Unassigned |
Bug Description
To reproduce the problem:
1. Run zsh on Ubuntu 22.04 LTS (also happens on 20.04 LTS)
2. Run vim and hit Control-Z to stop it
3. Enter "fg" to restore the stopped job
I expect fg to always be able to restore a stopped vim. Instead, sometimes vim stops itself again immediately after entering fg. The problem seems to be timing or scheduling related because it doesn't always occur.
This is due to a known bug in zsh versions 5.7, 5.7.1, 5.8, and 5.8.1. It was reported to the zsh project by Erik Paulson in June 2021, who also provided a one-line fix. The zsh project accepted Paulson's fix, which is now available in zsh 5.9.
The bug causes zsh to sometimes send two SIGCONT signals to the stopped job instead of only one. Certain programs behave unexpectedly when processing the second SIGCONT. vim stops itself. According to Paulson's bug report, emacsclient crashes.
Paulson's original bug report with patch:
https:/
The git commit that introduced the bug in Sept 2018:
https:/
The git commit of Paulson's fix:
https:/
The test program in this Stack Overflow question is a good way to reproduce the problem. With this program it is easy to see the two SIGCONT signals being sent sometimes by zsh fg:
https:/
ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: zsh 5.8.1-1
ProcVersionSign
Uname: Linux 5.15.0-46-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.1
Architecture: amd64
CasperMD5CheckR
Date: Sun Aug 28 14:06:07 2022
ProcEnviron:
TERM=screen.
PATH=(custom, no user)
XDG_RUNTIME_
LANG=C.UTF-8
SHELL=zsh
SourcePackage: zsh
UpgradeStatus: No upgrade log present (probably fresh install)
The attached patch for this bug applies to Ubuntu's zsh package 5.8.1-1. Original author is Erik Paulson. This fix is already in zsh 5.9.