Changeset 233979 in webkit


Ignore:
Timestamp:
Jul 19, 2018 1:24:27 AM (6 years ago)
Author:
commit-queue@webkit.org
Message:

[Flatpak] Let flatpak process handle SIGINT
https://bugs.webkit.org/show_bug.cgi?id=187521

Patch by Thibault Saunier <tsaunier@igalia.com> on 2018-07-19
Reviewed by Philippe Normand.

Ensuring that flatpak process ends properly and that the sandbox is teard down.
It also avoids showing usless backtrace to the end user and makes gdb
much more usable.

Also make flatpakutils not verbose by default

  • flatpak/flatpakutils.py:

(disable_signals):
(WebkitFlatpak.run_in_sandbox):
(WebkitFlatpak.run_gdb):

Location:
trunk/Tools
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Tools/ChangeLog

    r233944 r233979  
     12018-07-19  Thibault Saunier  <tsaunier@igalia.com>
     2
     3        [Flatpak] Let flatpak process handle SIGINT
     4        https://bugs.webkit.org/show_bug.cgi?id=187521
     5
     6        Reviewed by Philippe Normand.
     7
     8        Ensuring that flatpak process ends properly and that the sandbox is teard down.
     9        It also avoids showing usless backtrace to the end user and makes gdb
     10        much more usable.
     11
     12        Also make flatpakutils not verbose by default
     13
     14        * flatpak/flatpakutils.py:
     15        (disable_signals):
     16        (WebkitFlatpak.run_in_sandbox):
     17        (WebkitFlatpak.run_gdb):
     18
    1192018-07-18  Stephan Szabo  <stephan.szabo@sony.com>
    220
  • trunk/Tools/flatpak/flatpakutils.py

    r233681 r233979  
    2121except ImportError:
    2222    import ConfigParser as configparser
     23from contextlib import contextmanager
    2324import errno
    2425import json
     
    2627import shlex
    2728import shutil
     29import signal
    2830import subprocess
    2931import sys
     
    443445        self.flatpak("update", self.name, self.branch, show_output=True,
    444446                    *extra_args, comment=comment)
     447
     448
     449@contextmanager
     450def disable_signals(signals=[signal.SIGINT]):
     451    old_signal_handlers = []
     452
     453    for disabled_signal in signals:
     454        old_signal_handlers.append((disabled_signal, signal.getsignal(disabled_signal)))
     455        signal.signal(disabled_signal, signal.SIG_IGN)
     456
     457    yield
     458
     459    for disabled_signal, previous_handler in old_signal_handlers:
     460        signal.signal(disabled_signal, previous_handler)
    445461
    446462
     
    518534        self.app = None
    519535
    520         self.verbose = True
     536        self.verbose = False
    521537        self.quiet = False
    522538        self.packs = []
     
    705721            flatpak_command.extend(['sh', "/run/host/" + tmpscript.name])
    706722
    707             try:
    708                 subprocess.check_call(flatpak_command, stdout=stdout)
    709             except subprocess.CalledProcessError as e:
    710                 sys.stderr.write(str(e) + "\n")
    711                 return e.returncode
     723            with disable_signals():
     724                try:
     725                    subprocess.check_call(flatpak_command, stdout=stdout)
     726                except subprocess.CalledProcessError as e:
     727                    sys.stderr.write(str(e) + "\n")
     728                    return e.returncode
    712729
    713730        return 0
     
    795812
    796813    def run_gdb(self):
    797         try:
    798             subprocess.check_output(['which', 'coredumpctl'])
    799         except subprocess.CalledProcessError as e:
    800             sys.stderr.write("'coredumpctl' not present on the system, can't run. (%s)\n" % e)
    801             return e.returncode
     814        with disable_signals():
     815            try:
     816                subprocess.check_output(['which', 'coredumpctl'])
     817            except subprocess.CalledProcessError as e:
     818                sys.stderr.write("'coredumpctl' not present on the system, can't run. (%s)\n" % e)
     819                return e.returncode
    802820
    803821        # We need access to the host from the sandbox to run.
Note: See TracChangeset for help on using the changeset viewer.