當前位置: 首頁>>代碼示例>>Python>>正文


Python signal.SIGTTOU屬性代碼示例

本文整理匯總了Python中signal.SIGTTOU屬性的典型用法代碼示例。如果您正苦於以下問題:Python signal.SIGTTOU屬性的具體用法?Python signal.SIGTTOU怎麽用?Python signal.SIGTTOU使用的例子?那麽, 這裏精選的屬性代碼示例或許可以為您提供幫助。您也可以進一步了解該屬性所在signal的用法示例。


在下文中一共展示了signal.SIGTTOU屬性的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTTOU [as 別名]
def __init__(self, name, pid_dir='/var/run', signals=None):
        """
        Constructor.

        ``name`` is a string that identifies the daemon. The name is
        used for the name of the daemon process, the PID file and for
        the messages to syslog.

        ``pid_dir`` is the directory in which the PID file is stored.

        ``signals`` list of operating signals, that should be available
        for use with :py:meth:`.send_signal`, :py:meth:`.got_signal`,
        :py:meth:`.wait_for_signal`, and :py:meth:`.check_signal`. Note
        that SIGTERM is always supported, and that SIGTTIN, SIGTTOU, and
        SIGTSTP are never supported.
        """
        self.name = name
        self.pid_file = _PIDFile(os.path.join(pid_dir, name + '.pid'))
        self._signal_events = {int(s): threading.Event()
                               for s in ((signals or []) + [signal.SIGTERM])}
        self.logger = logging.getLogger(name)
        if not self.logger.handlers:
            self.logger.addHandler(logging.NullHandler())
        self.files_preserve = [] 
開發者ID:torfsen,項目名稱:service,代碼行數:26,代碼來源:__init__.py

示例2: make_default_signal_map

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTTOU [as 別名]
def make_default_signal_map():
    """ Make the default signal map for this system.

        The signals available differ by system. The map will not
        contain any signals not defined on the running system.

        """
    name_map = {
        'SIGTSTP': None,
        'SIGTTIN': None,
        'SIGTTOU': None,
        'SIGTERM': 'terminate',
        }
    signal_map = dict(
        (getattr(signal, name), target)
        for (name, target) in name_map.items()
        if hasattr(signal, name))

    return signal_map 
開發者ID:blackye,項目名稱:luscan-devel,代碼行數:21,代碼來源:daemon.py

示例3: make_default_signal_map

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTTOU [as 別名]
def make_default_signal_map():
    """ Make the default signal map for this system.

        The signals available differ by system. The map will not
        contain any signals not defined on the running system.

        """
    name_map = {
        'SIGTSTP': None,
        'SIGTTIN': None,
        'SIGTTOU': None,
        'SIGTERM': 'terminate',
    }
    signal_map = dict(
        (getattr(signal, name), target)
        for (name, target) in name_map.items()
        if hasattr(signal, name))

    return signal_map 
開發者ID:candlepin,項目名稱:virt-who,代碼行數:21,代碼來源:daemon.py

示例4: _handle_sigttou

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTTOU [as 別名]
def _handle_sigttou(self, signum, frame):
        #Had some issues that when memory corruptions occured in a subprocess
        #(no matter if shielded by multiprocess and subprocess module), 
        #that a SIGTTOU was sent to the entire Python main process.
        #According to https://en.wikipedia.org/wiki/SIGTTOU this
        #results in the process being stopped (and it looks like SIGSTP on the cmd):
        #[1]+  Stopped                 ./AflCrashAnalyzer.py
        #Of course we don't want that. Debugging was hard but then
        #realized after this program was stopped:
        #$ echo $?
        #150
        #So that's SIGTTOU on Linux at least.
        #This handler will prevent the process to stop.
        self.sigttou_flag = True
        try:
            self.current_process.kill()
        except OSError as ose:
            Logger.info("Kill failed. Sometimes the process exactly exits before we try to kill it... coward. Nothing to worry about.", ose) 
開發者ID:floyd-fuh,項目名稱:afl-crash-analyzer,代碼行數:20,代碼來源:Executer.py

示例5: test_default_rewrites_can_be_overriden_with_setsid_enabled

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTTOU [as 別名]
def test_default_rewrites_can_be_overriden_with_setsid_enabled():
    """In setsid mode, dumb-init should allow overwriting the default
    rewrites (but still suspend itself).
    """
    rewrite_map = {
        signal.SIGTTIN: signal.SIGTERM,
        signal.SIGTTOU: signal.SIGINT,
        signal.SIGTSTP: signal.SIGHUP,
    }
    with print_signals(_rewrite_map_to_args(rewrite_map)) as (proc, _):
        for send, expect_receive in rewrite_map.items():
            assert process_state(proc.pid) in ['running', 'sleeping']
            proc.send_signal(send)

            assert proc.stdout.readline() == '{}\n'.format(expect_receive).encode('ascii')
            os.waitpid(proc.pid, os.WUNTRACED)
            assert process_state(proc.pid) == 'stopped'

            proc.send_signal(signal.SIGCONT)
            assert proc.stdout.readline() == '{}\n'.format(signal.SIGCONT).encode('ascii')
            assert process_state(proc.pid) in ['running', 'sleeping'] 
開發者ID:Yelp,項目名稱:dumb-init,代碼行數:23,代碼來源:proxies_signals_test.py

示例6: _kill_old_workers

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTTOU [as 別名]
def _kill_old_workers(self, count: int) -> None:
        """
        Send signal to kill the worker.

        :param count: The number of workers to kill
        """
        for _ in range(count):
            count -= 1
            # TTOU: Decrement the number of processes by one
            self.gunicorn_master_proc.send_signal(signal.SIGTTOU)
            self._wait_until_true(
                lambda: self.num_workers_expected + count == self._get_num_workers_running(),
                timeout=self.master_timeout) 
開發者ID:apache,項目名稱:airflow,代碼行數:15,代碼來源:webserver_command.py

示例7: is_stop_signal

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTTOU [as 別名]
def is_stop_signal(signum):
    return signum in (signal.SIGSTOP, signal.SIGTSTP,
                      signal.SIGTTIN, signal.SIGTTOU) 
開發者ID:pinterest,項目名稱:ptracer,代碼行數:5,代碼來源:ptrace.py

示例8: _stop_backdoor_server

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTTOU [as 別名]
def _stop_backdoor_server(signum, frame):
    def _stop():
        server = ServeBackdoor.get_instance()
        if server:
            logger.info('stopping backdoor server on %r...', server.addr)
            server.kill()

    ignore_sig(signal.SIGTTOU)
    gevent.spawn(_stop()) 
開發者ID:huskar-org,項目名稱:huskar,代碼行數:11,代碼來源:signal.py

示例9: run_command

# 需要導入模塊: import signal [as 別名]
# 或者: from signal import SIGTTOU [as 別名]
def run_command(self, command, timeout=None, env={}, stdout=file("/dev/null"), stderr=file("/dev/null")):
        #TODO: make stdout / stderr configurable
        if not timeout:
            timeout = self.config.run_timeout
        process = subprocess.Popen(command, stdin=None, shell=False, stdout=stdout, stderr=stderr)
        self.current_process = process
        signal.signal(signal.SIGALRM, self._handle_alarm)
        #We also had a problem that memory corruptions...
        signal.signal(signal.SIGTTOU, self._handle_sigttou)
        signal.alarm(timeout)
        self.timeout_flag = False
        self.sigttou_flag = False
        #TODO: get rid of magic number
        ret_signal = self.TIMEOUT_SIGNAL
        #blocking call:
        process.communicate()
        signal.alarm(0)
        #This line is reached when timeout_flag was set by _handle_alarm if it was called
        if self.timeout_flag:
            Logger.debug("Process was killed as it exceeded the time limit", debug_level=3)
            ret_signal = self.TIMEOUT_SIGNAL
        elif self.sigttou_flag:
            Logger.debug("Some memory corruption resulted in a SIGTTOU signal being thrown (usually stops process). We caught it.", debug_level=3)
            ret_signal = signal.SIGTTOU
        else:
            ret_signal = process.returncode
        return ret_signal 
開發者ID:floyd-fuh,項目名稱:afl-crash-analyzer,代碼行數:29,代碼來源:Executer.py


注:本文中的signal.SIGTTOU屬性示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。