Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fish exits when receiving Ctrl-C as a subprocess #5909

Closed
dlo9 opened this issue May 31, 2019 · 1 comment
Closed

Fish exits when receiving Ctrl-C as a subprocess #5909

dlo9 opened this issue May 31, 2019 · 1 comment

Comments

@dlo9
Copy link

@dlo9 dlo9 commented May 31, 2019

When spawned as a subprocess (only tested via python's subprocess.run()), hitting ctrl-c to send a SIGINT interrupt signal causes the shell to exit and return control to the parent process, instead of consuming the interrupt like a normally spawned shell. This does not occur when spawning other shells (I tested bash & zsh) in the same manner, but appears to be fish-specific.

This has been very annoying when using iocage to manage FreeBSD jails, as it unexpectedly exits the jail and appears to corrupt input in the parent shell -- however, I've never naturally encountered the issue outside that workflow.

Steps to reproduce:

  1. Run the following python code to spawn a new shell:
import subprocess

try:
    subprocess.run(["fish", "-i"])
    # User hits ctrl-c here
except KeyboardInterrupt:
    print("Aborted!")
  1. Hit ctrl-c to send an interrupt, and you will see "Aborted!", indicating the subprocess has exited

Spawning a different shell (e.g. subprocess.run(["bash", "-i"])) does not reproduce this behavior. Further, if the parent shell is bash instead of fish, typed characters do not display on the terminal after the subprocess's exit, but will register as a command once Enter is pressed.

I noticed that bash (and other shells) are the leader of their own process group during this maneuver, and fish is not. I'm not well-versed on process-control flow, but this seems related since signals from the terminal are sent to all processes in the foreground process group:

> ps a -o pid,pgid,tpgid,command | grep -A2 "python ctrl_c.py"
  PID  PGID TPGID COMMAND
----------------------------------
20187 20187 20188 python ctrl_c.py
20188 20188 20188 bash -i
----------------------------------
19997 19997 19997 python ctrl_c.py
19998 19997 19997 fish -i
  • fish: 3.0.2
  • OS: Arch Linux
  • Terminal: urxvt (rxvt-unicode-256color)
  • Third-party customizations have no effect
@ridiculousfish
Copy link
Member

@ridiculousfish ridiculousfish commented Jun 1, 2019

Probably fish should attempt to become process group leader when launched with the explicit -i flag.

@ridiculousfish ridiculousfish added this to the fish-future milestone Jun 1, 2019
MathieuDuponchelle added a commit to MathieuDuponchelle/fish-shell that referenced this issue Dec 12, 2019
krobelus pushed a commit to krobelus/fish-shell that referenced this issue Dec 19, 2019
krobelus pushed a commit to krobelus/fish-shell that referenced this issue Dec 19, 2019
@zanchey zanchey removed this from the fish-future milestone Dec 23, 2019
@zanchey zanchey added this to the fish 3.1.0 milestone Dec 23, 2019
@zanchey zanchey removed this from the fish 3.1.0 milestone Dec 23, 2019
@zanchey zanchey added this to the fish-future milestone Dec 23, 2019
@zanchey zanchey removed this from the fish-future milestone Dec 23, 2019
@zanchey zanchey added this to the fish 3.1.0 milestone Dec 23, 2019
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants