本文整理匯總了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]