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


Python GNUScreen._get_tty_pids_pgrep方法代码示例

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


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

示例1: kill_win_last_proc

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import _get_tty_pids_pgrep [as 别名]
def kill_win_last_proc(session,win="-1",sig="TERM"):
    import signal,os,platform
    ss=ScreenSaver(session,'/dev/null','/dev/null')
    ctty=ss.tty(win)
    if platform.system() == 'FreeBSD':
        pids=sc.get_tty_pids(ctty)
    else:
        pids=sc._get_tty_pids_pgrep(ctty)
    pid = pids[-1]

    sig=eval('signal.SIG'+sig)
    os.kill(int(pid),sig)
开发者ID:brendoncrawford,项目名称:screen-session,代码行数:14,代码来源:tools.py

示例2: get_win_last_proc

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import _get_tty_pids_pgrep [as 别名]
def get_win_last_proc(session, win="-1", ctty = None):
    import platform
    if not ctty:
        ss = ScreenSaver(session, '/dev/null', '/dev/null')
        ctty = ss.tty(win)
    if ctty is None or ctty == -1:
        stderr.write("Window does not exist (%s)\n" % win)
        return False
    if platform.system() == 'FreeBSD':
        pids = sc.get_tty_pids(ctty)
    else:
        pids = sc._get_tty_pids_pgrep(ctty)
    if len(pids) > 0:
        return pids[-1]
    else:

        ## No processes for this window.

        return None
开发者ID:chronidev,项目名称:screen-session,代码行数:21,代码来源:tools.py

示例3: for

# 需要导入模块: import GNUScreen [as 别名]
# 或者: from GNUScreen import _get_tty_pids_pgrep [as 别名]
    cwin = sc.get_current_window(session)

if tdir.startswith('/') or tdir.startswith('~'):
    thedir = os.path.expanduser(tdir)
else:
    if sourcenumber == "-1":
        f = os.popen(SCREEN + ' %s -Q @tty' % session_arg)
    else:
        f = os.popen(SCREEN + ' %s -p %s -Q @tty' % (session_arg, sourcenumber))
    ctty = f.readline()
    f.close()
    if ctty.startswith('/dev'):
        if platform.system() == 'FreeBSD':
            pids = sc.get_tty_pids(ctty)
        else:
            pids = sc._get_tty_pids_pgrep(ctty)

        try:
            p_i = [i for (i, x) in enumerate(pids) if x == ppid][0] - 1
            thepid = pids[p_i]
        except:
            p_i = len(pids) - 1
            thepid = pids[p_i]

        info = None
        while not info and p_i >= 0:
            try:
                info = sc.get_pid_info(thepid)
            except:
                p_i -= 1
                thepid = pids[p_i]
开发者ID:chronidev,项目名称:screen-session,代码行数:33,代码来源:new-window.py


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