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

when started from python's subprocess.call(), fish does not handle ctrl-c properly. #6261

Closed
etoombs-encircle opened this issue Oct 29, 2019 · 1 comment

Comments

@etoombs-encircle
Copy link

Version, etc:

$ pacman -Qi fish python3 | egrep 'Name|Version'
Name            : fish
Version         : 3.0.2-2
Name            : python
Version         : 3.7.4-2
$ uname -s -r -v -m -o
Linux 5.3.7-arch1-1-ARCH #1 SMP PREEMPT Fri Oct 18 00:17:03 UTC 2019 x86_64 GNU/Linux

So, first, you start fish using subprocess.call(). Then, you try a ^C at the prompt. It's supposed to just reset the prompt state. This is what it does instead:

env -i HOME=(mktemp -d) TERM=xterm-256color python3 -c 'from subprocess import *; call(["fish"])'
Welcome to fish, the friendly interactive shell
eric@<hostname> /h/eric> Traceback (most recent call last):
  File "<string>", line 1, in <module>
  File "/usr/lib/python3.7/subprocess.py", line 325, in call
    return p.wait(timeout=timeout)
  File "/usr/lib/python3.7/subprocess.py", line 990, in wait
    return self._wait(timeout=timeout)
  File "/usr/lib/python3.7/subprocess.py", line 1624, in _wait
    (pid, sts) = self._try_wait(0)
  File "/usr/lib/python3.7/subprocess.py", line 1582, in _try_wait
    (pid, sts) = os.waitpid(self.pid, wait_flags)
KeyboardInterrupt

I'd normally blame python, but this only seems to happen when using fish. Here's what happens when you use bash, for example:

env -i HOME=(mktemp -d) TERM=xterm-256color python3 -c 'from subprocess import *; call(["bash"])'
[eric@<hostname> eric]$ ^C
[eric@<hostname> eric]$ ^C
[eric@<hostname> eric]$ ^C
[eric@<hostname> eric]$ exit

If you swap the subprocess.call() function for an os.execvp(), it works fine. I tested it in xfce4-terminal and the linux terminal and saw the same behaviour in both places.
I guess this might still be a problem with python. IDK, what do you think?

@zanchey
Copy link
Member

zanchey commented Oct 30, 2019

bash starts a new process group, where fish doesn't:

USER    PID  PPID  PGID   SESS JOBC STAT   TT       TIME COMMAND
david 23932 23836 23932      0    1 S+   s007    0:00.07 /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3
david 23933 23932 23932      0    1 S+   s007    0:00.11 /usr/local/bin/fish
david 23959 23940 23959      0    1 S    s008    0:00.08 /usr/local/Cellar/python/3.7.4_1/Frameworks/Python.framework/Versions/3
david 23960 23959 23960      0    1 S+   s008    0:00.01 bash

This is a duplicate of #5909.

@zanchey zanchey closed this as completed Oct 30, 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

2 participants