# Path: ranger/ext/popen_forked.py
# def Popen_forked(*args, **kwargs):  # pylint: disable=invalid-name
#     """Forks process and runs Popen with the given args and kwargs.
# 
#     Returns True if forking succeeded, otherwise False.
#     """
#     try:
#         pid = os.fork()
#     except OSError:
#         return False
#     if pid == 0:
#         os.setsid()
#         with open(os.devnull, 'r', encoding="utf-8") as null_r, open(
#             os.devnull, 'w', encoding="utf-8"
#         ) as null_w:
#             kwargs['stdin'] = null_r
#             kwargs['stdout'] = kwargs['stderr'] = null_w
#             Popen(*args, **kwargs)
#         os._exit(0)  # pylint: disable=protected-access
#     else:
#         os.wait()
#     return True


import logging
import os
import sys
from io import open
from subprocess import Popen, PIPE, STDOUT
from ranger.ext.get_executables import get_executables, get_term
from ranger.ext.popen_forked import Popen_forked
                action = ['sudo'] + (f_flag and ['-b'] or []) + action
            toggle_ui = True
            context.wait = True
        if 't' in context.flags:
            if not ('WAYLAND_DISPLAY' in os.environ
                    or sys.platform == 'darwin'
                    or 'DISPLAY' in os.environ):
                return self._log("Can not run with 't' flag, no display found!")
            term = get_term()
            if isinstance(action, str):
                action = term + ' -e ' + action
            else:
                action = [term, '-e'] + action
            toggle_ui = False
            context.wait = False

        popen_kws['args'] = action
        # Finally, run it

        if toggle_ui:
            self._activate_ui(False)
        try:
            error = None
            process = None
            self.fm.signal_emit('runner.execute.before',
                                popen_kws=popen_kws, context=context)
            try:
                if 'f' in context.flags and 'r' not in context.flags:
                    # This can fail and return False if os.fork() is not
                    # supported, but we assume it is, since curses is used.

# Path: ranger/ext/popen_forked.py
# def Popen_forked(*args, **kwargs):  # pylint: disable=invalid-name
#     """Forks process and runs Popen with the given args and kwargs.
# 
#     Returns True if forking succeeded, otherwise False.
#     """
#     try:
#         pid = os.fork()
#     except OSError:
#         return False
#     if pid == 0:
#         os.setsid()
#         with open(os.devnull, 'r', encoding="utf-8") as null_r, open(
#             os.devnull, 'w', encoding="utf-8"
#         ) as null_w:
#             kwargs['stdin'] = null_r
#             kwargs['stdout'] = kwargs['stderr'] = null_w
#             Popen(*args, **kwargs)
#         os._exit(0)  # pylint: disable=protected-access
#     else:
#         os.wait()
#     return True


# Path: ranger/core/runner.py
import logging
import os
import sys
from io import open
from subprocess import Popen, PIPE, STDOUT
from ranger.ext.get_executables import get_executables, get_term
from ranger.ext.popen_forked import Popen_forked

                action = ['sudo'] + (f_flag and ['-b'] or []) + action
            toggle_ui = True
            context.wait = True
        if 't' in context.flags:
            if not ('WAYLAND_DISPLAY' in os.environ
                    or sys.platform == 'darwin'
                    or 'DISPLAY' in os.environ):
                return self._log("Can not run with 't' flag, no display found!")
            term = get_term()
            if isinstance(action, str):
                action = term + ' -e ' + action
            else:
                action = [term, '-e'] + action
            toggle_ui = False
            context.wait = False

        popen_kws['args'] = action
        # Finally, run it

        if toggle_ui:
            self._activate_ui(False)
        try:
            error = None
            process = None
            self.fm.signal_emit('runner.execute.before',
                                popen_kws=popen_kws, context=context)
            try:
                if 'f' in context.flags and 'r' not in context.flags:
                    # This can fail and return False if os.fork() is not
                    # supported, but we assume it is, since curses is used.

                    Popen_forked(**popen_kws)