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


Python os.tcsetpgrp方法代碼示例

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


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

示例1: test_tcsetpgrpt

# 需要導入模塊: import os [as 別名]
# 或者: from os import tcsetpgrp [as 別名]
def test_tcsetpgrpt(self):
        self.check(os.tcsetpgrp, 0) 
開發者ID:IronLanguages,項目名稱:ironpython2,代碼行數:4,代碼來源:test_os.py

示例2: test_tcsetpgrpt

# 需要導入模塊: import os [as 別名]
# 或者: from os import tcsetpgrp [as 別名]
def test_tcsetpgrpt(self):
        if hasattr(os, "tcsetpgrp"):
            self.check(os.tcsetpgrp, 0) 
開發者ID:dxwu,項目名稱:BinderFilter,代碼行數:5,代碼來源:test_os.py

示例3: _controlTerminal

# 需要導入模塊: import os [as 別名]
# 或者: from os import tcsetpgrp [as 別名]
def _controlTerminal(self):
        try:
            # the child should control stdin -- if stdin is a tty
            # that can be controlled
            if sys.stdin.isatty():
                os.tcsetpgrp(0, os.getpgrp())
        except AttributeError:
           # stdin might not even have an isatty method
            pass 
開發者ID:sassoftware,項目名稱:conary,代碼行數:11,代碼來源:logger.py

示例4: close

# 需要導入模塊: import os [as 別名]
# 或者: from os import tcsetpgrp [as 別名]
def close(self):
        """ Reassert control of tty.  Closing stdin, stderr, and and stdout
            will get rid of the last pointer to the slave fd of the pseudo
            tty, which should cause the logging process to stop.  We wait
            for it to die before continuing
        """
        if not self.logging:
            return
        self.closed = True
        # restore old terminal settings before quitting
        if self.oldStdin != 0:
            os.dup2(self.oldStdin, 0)
        os.dup2(self.oldStdout, 1)
        os.dup2(self.oldStderr, 2)
        if self.oldTermios is not None:
            termios.tcsetattr(0, termios.TCSADRAIN, self.oldTermios)
        if self.oldStdin != 0:
            os.close(self.oldStdin)
        os.close(self.oldStdout)
        os.close(self.oldStderr)
        try:
            # control stdin -- if stdin is a tty
            # that can be controlled
            if sys.stdin.isatty() and self.restoreTerminalControl:
                os.tcsetpgrp(0, os.getpgrp())
        except AttributeError:
            # stdin might not even have an isatty method
            pass

        # Wait for child logging process to die.  Send successively ruder
        # signals if it does not do so within a reasonable time.  The primary
        # reason that it would not die immediately is that a process has forked
        # while holding the TTY file descriptor, and thus the logger is still
        # polling it for output.
        signals = [signal.SIGTERM, signal.SIGKILL]
        while signals:
            start = time.time()
            while time.time() - start < 10:
                pid, status = os.waitpid(self.loggerPid, os.WNOHANG)
                if pid:
                    break
                time.sleep(0.1)
            else:
                # Child process did not die.
                signum = signals.pop(0)
                os.kill(self.loggerPid, signum)
                continue
            break
        else:
            # Last signal was a KILL, so wait indefinitely.
            os.waitpid(self.loggerPid, 0) 
開發者ID:sassoftware,項目名稱:conary,代碼行數:53,代碼來源:logger.py


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