Skip to content

Commit

Permalink
Change startProgram preexec check to early exit style
Browse files Browse the repository at this point in the history
This is what we do elsewhere
  • Loading branch information
VladimirSlavik committed Jul 12, 2023
1 parent 9efd336 commit 0fd50ca
Showing 1 changed file with 25 additions and 24 deletions.
49 changes: 25 additions & 24 deletions pyanaconda/core/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,30 +137,31 @@ def startProgram(argv, root='/', stdin=None, stdout=subprocess.PIPE, stderr=subp
close_fds=True,
restore_signals=restore_signals,
cwd=root, env=env, **kwargs)
if do_preexec:
# Check for and save a preexec_fn argument
preexec_fn = kwargs.pop("preexec_fn", None)

def preexec():
# If a target root was specificed, chroot into it
if target_root and target_root != '/':
os.chroot(target_root)
os.chdir("/")

# Signal handlers set to SIG_IGN persist across exec. Reset
# these to SIG_DFL if requested. In particular this will include the
# SIGPIPE handler set by python.
if reset_handlers:
for signum in range(1, signal.NSIG):
if signal.getsignal(signum) == signal.SIG_IGN:
signal.signal(signum, signal.SIG_DFL)

# If the user specified an additional preexec_fn argument, run it
if preexec_fn is not None:
preexec_fn()

return partsubp(preexec_fn=preexec)
return partsubp()
if not do_preexec:
return partsubp()

# Check for and save a preexec_fn argument
preexec_fn = kwargs.pop("preexec_fn", None)

def preexec():
# If a target root was specificed, chroot into it
if target_root and target_root != '/':
os.chroot(target_root)
os.chdir("/")

# Signal handlers set to SIG_IGN persist across exec. Reset
# these to SIG_DFL if requested. In particular this will include the
# SIGPIPE handler set by python.
if reset_handlers:
for signum in range(1, signal.NSIG):
if signal.getsignal(signum) == signal.SIG_IGN:
signal.signal(signum, signal.SIG_DFL)

# If the user specified an additional preexec_fn argument, run it
if preexec_fn is not None:
preexec_fn()

return partsubp(preexec_fn=preexec)


class X11Status:
Expand Down

0 comments on commit 0fd50ca

Please sign in to comment.