fg in zsh sometimes fails to restore stopped job

Bug #1987991 reported by Matt Day
This bug affects 1 person
Affects Status Importance Assigned to Milestone
zsh (Ubuntu)

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:

The git commit that introduced the bug in Sept 2018:

The git commit of Paulson's fix:

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:

ProblemType: Bug
DistroRelease: Ubuntu 22.04
Package: zsh 5.8.1-1
ProcVersionSignature: Ubuntu 5.15.0-46.49-generic 5.15.39
Uname: Linux 5.15.0-46-generic x86_64
ApportVersion: 2.20.11-0ubuntu82.1
Architecture: amd64
CasperMD5CheckResult: unknown
Date: Sun Aug 28 14:06:07 2022
 PATH=(custom, no user)
SourcePackage: zsh
UpgradeStatus: No upgrade log present (probably fresh install)

Revision history for this message
Matt Day (fjarlq) wrote :
Matt Day (fjarlq)
description: updated
Revision history for this message
Matt Day (fjarlq) wrote :

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.

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "zsh-fg.diff" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.