本文整理汇总了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)
示例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
示例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]