MCPcopy
hub / github.com/treeverse/dvc / _posix_detached_subprocess

Function _posix_detached_subprocess

dvc/daemon.py:100–116  ·  view source on GitHub ↗
(args: Sequence[str], **kwargs)

Source from the content-addressed store, hash-verified

98
99
100def _posix_detached_subprocess(args: Sequence[str], **kwargs) -> int:
101 # double fork and execute a subprocess so that there are no zombies
102 read_end, write_end = os.pipe()
103 pid = _fork_process()
104 if pid > 0: # in parent
105 os.close(write_end)
106 pid_str = os.read(read_end, 32).decode("utf8")
107 os.close(read_end)
108 return int(pid_str)
109
110 proc = subprocess.Popen(args, shell=False, close_fds=True, **kwargs) # noqa: S603
111 os.close(read_end)
112 os.write(write_end, str(proc.pid).encode("utf8"))
113 os.close(write_end)
114
115 exit_code = proc.wait()
116 os._exit(exit_code)
117
118
119def _detached_subprocess(args: Sequence[str], **kwargs) -> int:

Callers 1

_detached_subprocessFunction · 0.85

Calls 5

_fork_processFunction · 0.85
writeMethod · 0.80
waitMethod · 0.80
closeMethod · 0.45
readMethod · 0.45

Tested by

no test coverage detected