gst-env: Ignore SIGINT when using the fish shell
authorNirbheek Chauhan <nirbheek@centricular.com>
Wed, 18 Dec 2019 20:44:30 +0000 (02:14 +0530)
committerNirbheek Chauhan <nirbheek@centricular.com>
Wed, 18 Dec 2019 20:44:30 +0000 (02:14 +0530)
After discussion with fish upstream it looks like it will take some
work to fix this issue.

https://github.com/fish-shell/fish-shell/pull/6426#issuecomment-567174105

In the meantime, this only happens when there's no command running in
the terminal, and in that case the shell just ignores it anyway. So
just do that in `gst-env.py`.

Fixes https://gitlab.freedesktop.org/gstreamer/gst-build/issues/18

gst-env.py

index ad00cd8..6419642 100755 (executable)
@@ -12,6 +12,7 @@ import subprocess
 import sys
 import tempfile
 import pathlib
+import signal
 
 from distutils.sysconfig import get_python_lib
 from distutils.util import strtobool
@@ -384,6 +385,11 @@ if __name__ == "__main__":
             # Let the GC remove the tmp file
             args.append("--rcfile")
             args.append(tmprc.name)
+        if 'fish' in args[0]:
+            # Ignore SIGINT while using fish as the shell to make it behave
+            # like other shells such as bash and zsh.
+            # See: https://gitlab.freedesktop.org/gstreamer/gst-build/issues/18
+            signal.signal(signal.SIGINT, lambda x, y: True)
     try:
         exit(subprocess.call(args, close_fds=False,
                              env=get_subprocess_env(options, gst_version)))