当前位置: 首页>>代码示例>>Python>>正文


Python os.getsid方法代码示例

本文整理汇总了Python中os.getsid方法的典型用法代码示例。如果您正苦于以下问题:Python os.getsid方法的具体用法?Python os.getsid怎么用?Python os.getsid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在os的用法示例。


在下文中一共展示了os.getsid方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: _check_ioctl_mutate_len

# 需要导入模块: import os [as 别名]
# 或者: from os import getsid [as 别名]
def _check_ioctl_mutate_len(self, nbytes=None):
        buf = array.array('i')
        intsize = buf.itemsize
        ids = (os.getpgrp(), os.getsid(0))
        # A fill value unlikely to be in `ids`
        fill = -12345
        if nbytes is not None:
            # Extend the buffer so that it is exactly `nbytes` bytes long
            buf.extend([fill] * (nbytes // intsize))
            self.assertEqual(len(buf) * intsize, nbytes)   # sanity check
        else:
            buf.append(fill)
        with open("/dev/tty", "r") as tty:
            r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
        rpgrp = buf[0]
        self.assertEqual(r, 0)
        self.assertIn(rpgrp, ids) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:19,代码来源:test_ioctl.py

示例2: kill_em_all

# 需要导入模块: import os [as 别名]
# 或者: from os import getsid [as 别名]
def kill_em_all(sig, frame):
    """
        Terminate all processes while capturing a SIGINT from the user
    """
    logger_gen.info('CTRL-C received, exiting')
    if is_windows():
        multiprocessing.sys.exit(1)
    
    else:
        pid = os.getpid()
        pgid = os.getpgid(pid)
        sid = os.getsid(os.getpid())
        
        # if launched with --no-xserver
        if pid == sid:
            os.killpg(pgid, signal.SIGKILL)
        else:
            time.sleep(4)
            multiprocessing.sys.exit(1) 
开发者ID:maaaaz,项目名称:webscreenshot,代码行数:21,代码来源:webscreenshot.py

示例3: _check_ioctl_mutate_len

# 需要导入模块: import os [as 别名]
# 或者: from os import getsid [as 别名]
def _check_ioctl_mutate_len(self, nbytes=None):
        buf = array.array('i')
        intsize = buf.itemsize
        ids = (os.getpgrp(), os.getsid(0))
        # A fill value unlikely to be in `ids`
        fill = -12345
        if nbytes is not None:
            # Extend the buffer so that it is exactly `nbytes` bytes long
            buf.extend([fill] * (nbytes // intsize))
            self.assertEqual(len(buf) * intsize, nbytes)   # sanity check
        else:
            buf.append(fill)
        with open("/dev/tty", "rb") as tty:
            r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
        rpgrp = buf[0]
        self.assertEqual(r, 0)
        self.assertIn(rpgrp, ids) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:19,代码来源:test_ioctl.py

示例4: test_ioctl

# 需要导入模块: import os [as 别名]
# 或者: from os import getsid [as 别名]
def test_ioctl(self):
        # If this process has been put into the background, TIOCGPGRP returns
        # the session ID instead of the process group id.
        ids = (os.getpgrp(), os.getsid(0))
        tty = open("/dev/tty", "r")
        r = fcntl.ioctl(tty, termios.TIOCGPGRP, "    ")
        rpgrp = struct.unpack("i", r)[0]
        self.assertIn(rpgrp, ids) 
开发者ID:IronLanguages,项目名称:ironpython2,代码行数:10,代码来源:test_ioctl.py

示例5: test_ioctl

# 需要导入模块: import os [as 别名]
# 或者: from os import getsid [as 别名]
def test_ioctl(self):
        # If this process has been put into the background, TIOCGPGRP returns
        # the session ID instead of the process group id.
        ids = (os.getpgrp(), os.getsid(0))
        with open("/dev/tty", "rb") as tty:
            r = fcntl.ioctl(tty, termios.TIOCGPGRP, "    ")
            rpgrp = struct.unpack("i", r)[0]
            self.assertIn(rpgrp, ids) 
开发者ID:Microvellum,项目名称:Fluid-Designer,代码行数:10,代码来源:test_ioctl.py

示例6: get_sid

# 需要导入模块: import os [as 别名]
# 或者: from os import getsid [as 别名]
def get_sid(self):
        """ return the CURRENT session id of the process. this differs from
        self.sid in that this refects the current state of the process, where
        self.sid is the session id at launch """
        return os.getsid(self.pid) 
开发者ID:acaceres2176,项目名称:scylla,代码行数:7,代码来源:sh.py

示例7: childproc_filialusurp

# 需要导入模块: import os [as 别名]
# 或者: from os import getsid [as 别名]
def childproc_filialusurp(umask, chdir, umask_path, sid_path, wdir_path,
                          pid_path):
    _filial_usurpation(chdir, umask)
    # Get our session id
    my_pid = os.getpid()
    sid = os.getsid(my_pid)
    # reset umask and get our set one.
    umask = os.umask(0)
    # Get our working directory.
    wdir = os.path.abspath(os.getcwd())
    
    # Update parent
    # Write the umask to the response path
    with open(umask_path, 'w') as f:
        f.write(str(umask) + '\n')
        
    # Write the sid to the response path
    with open(sid_path, 'w') as f:
        f.write(str(sid) + '\n')
        
    # Write the working dir to the response path
    with open(wdir_path, 'w') as f:
        f.write(wdir + '\n')
        
    # Write the pid to the response path
    with open(pid_path, 'w') as f:
        f.write(str(my_pid) + '\n')


# ###############################################
# Testing
# ############################################### 
开发者ID:Muterra,项目名称:py_daemoniker,代码行数:34,代码来源:test_daemonize_unix.py

示例8: test_ioctl

# 需要导入模块: import os [as 别名]
# 或者: from os import getsid [as 别名]
def test_ioctl(self):
        # If this process has been put into the background, TIOCGPGRP returns
        # the session ID instead of the process group id.
        ids = (os.getpgrp(), os.getsid(0))
        tty = open("/dev/tty", "r")
        r = fcntl.ioctl(tty, termios.TIOCGPGRP, "    ")
        rpgrp = struct.unpack("i", r)[0]
        self.assert_(rpgrp in ids, "%s not in %s" % (rpgrp, ids)) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:10,代码来源:test_ioctl.py

示例9: test_ioctl_mutate

# 需要导入模块: import os [as 别名]
# 或者: from os import getsid [as 别名]
def test_ioctl_mutate(self):
        import array
        buf = array.array('i', [0])
        ids = (os.getpgrp(), os.getsid(0))
        tty = open("/dev/tty", "r")
        r = fcntl.ioctl(tty, termios.TIOCGPGRP, buf, 1)
        rpgrp = buf[0]
        self.assertEquals(r, 0)
        self.assert_(rpgrp in ids, "%s not in %s" % (rpgrp, ids)) 
开发者ID:ofermend,项目名称:medicare-demo,代码行数:11,代码来源:test_ioctl.py

示例10: close

# 需要导入模块: import os [as 别名]
# 或者: from os import getsid [as 别名]
def close(self) -> None:
        if self.closed:
            raise channel.ChannelClosedException()

        sid = os.getsid(self.p.pid)
        self.p.terminate()
        os.close(self.pty_master)
        self.p.wait()

        # Wait for all processes in the session to end.  Most of the time
        # this will return immediately, but in some cases (eg. a serial session
        # with picocom) we have to wait a bit until we can continue.  To be as
        # quick as possible this is implemented as exponential backoff and will
        # give up after 1 second (1.27 to be exact) and emit a warning.
        for t in range(7):
            if (
                subprocess.call(
                    ["ps", "-s", str(sid)],
                    stdout=subprocess.DEVNULL,
                    stderr=subprocess.DEVNULL,
                )
                != 0
            ):
                break
            time.sleep(2 ** t / 100)
        else:
            raise Exception("not done") 
开发者ID:Rahix,项目名称:tbot,代码行数:29,代码来源:subprocess.py


注:本文中的os.getsid方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。