mirror of
https://github.com/freedomofpress/dangerzone.git
synced 2025-04-28 18:02:38 +02:00
Always start conversion process in new session
Start the conversion process in a new session, so that we can later on kill the process group, without killing the controlling script (i.e., the Dangezone UI). This should not affect the conversion process in any other way.
This commit is contained in:
parent
8d856ff4c3
commit
b9a3dd63ad
5 changed files with 13 additions and 1 deletions
|
@ -259,6 +259,11 @@ class IsolationProvider(ABC):
|
|||
) -> Iterator[subprocess.Popen]:
|
||||
"""Start a conversion process, pass it to the caller, and then clean it up."""
|
||||
p = self.start_doc_to_pixels_proc(document)
|
||||
if platform.system() != "Windows":
|
||||
assert os.getpgid(p.pid) != os.getpgid(
|
||||
os.getpid()
|
||||
), "Parent shares same PGID with child"
|
||||
|
||||
try:
|
||||
yield p
|
||||
except errors.ConverterProcException as e:
|
||||
|
|
|
@ -267,6 +267,9 @@ class Container(IsolationProvider):
|
|||
stdout=subprocess.PIPE,
|
||||
stderr=self.proc_stderr,
|
||||
startupinfo=startupinfo,
|
||||
# Start the conversion process in a new session, so that we can later on
|
||||
# kill the process group, without killing the controlling script.
|
||||
start_new_session=True,
|
||||
)
|
||||
|
||||
def exec_container(
|
||||
|
|
|
@ -73,7 +73,7 @@ class Dummy(IsolationProvider):
|
|||
pass
|
||||
|
||||
def start_doc_to_pixels_proc(self, document: Document) -> subprocess.Popen:
|
||||
return subprocess.Popen("True")
|
||||
return subprocess.Popen("True", start_new_session=True)
|
||||
|
||||
def terminate_doc_to_pixels_proc(
|
||||
self, document: Document, p: subprocess.Popen
|
||||
|
|
|
@ -67,6 +67,9 @@ class Qubes(IsolationProvider):
|
|||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=stderr,
|
||||
# Start the conversion process in a new session, so that we can later on
|
||||
# kill the process group, without killing the controlling script.
|
||||
start_new_session=True,
|
||||
)
|
||||
|
||||
if dev_mode:
|
||||
|
|
|
@ -25,6 +25,7 @@ class DummyWait(Dummy):
|
|||
stdin=subprocess.PIPE,
|
||||
stdout=subprocess.PIPE,
|
||||
stderr=subprocess.PIPE,
|
||||
start_new_session=True,
|
||||
)
|
||||
|
||||
def terminate_doc_to_pixels_proc(
|
||||
|
|
Loading…
Reference in a new issue