mrrl-containers

MRRL version of container scripts
git clone https://ccx.te2000.cz/git/mrrl-containers
Log | Files | Refs

commit fcab3bfb7fd2cbcc9af7fd17ca69dd150f3f439d
parent 7376f66811749cb476645c11f16c65e0ba82c01b
Author: Jan Pobříslo <ccx@te2000.cz>
Date:   Thu, 16 Dec 2021 15:36:41 +0000

Wait and fork fixes in pidns_run
Diffstat:
Msbin/pidns_run | 14++++++++------
1 file changed, 8 insertions(+), 6 deletions(-)

diff --git a/sbin/pidns_run b/sbin/pidns_run @@ -36,17 +36,19 @@ def main(argv): if libc.unshare(CLONE_NEWPID) != 0: raise OSError(ctypes.get_errno()) fork_pid = os.fork() - if fork_pid: + if fork_pid == 0: # child os.close(parent_wfd) fork2_pid = os.fork() - if fork2_pid: + if fork2_pid == 0: # child + env = dict(os.environ) + # env['NS_NO_PID1'] = "1" if argv[1][0] == '/': - os.execve(argv[1], argv[1:]) + os.execve(argv[1], argv[1:], env) for d in os.environ['PATH'].split(':'): try: - os.execv(os.path.join(d, argv[1]), argv[1:]) + os.execv(os.path.join(d, argv[1]), argv[1:], env) except FileNotFoundError: continue raise SystemExit(127) @@ -55,7 +57,7 @@ def main(argv): rlist, wlist, elist = (parent_rfd), (), () while True: (pid, status) = os.waitpid(0, os.WNOHANG) - if pid: + if pid == fork2_pid: exit_status(status) try: r, w, x = select.select(rlist, wlist, elist, timeout=1.0) @@ -67,7 +69,7 @@ def main(argv): else: # parent os.close(parent_rfd) - (pid, status) = os.waitpid(fork_pid) + (pid, status) = os.waitpid(fork_pid, 0) exit_status(status)