Example #1
0
def isInteractivePosix():
    try:
        import posix
        tty = open("/dev/tty")
        tpgrp = posix.tcgetpgrp(tty.fileno())
        pgrp = posix.getpgrp()
        tty.close()
        return (tpgrp == pgrp)
    finally:
        return False
Example #2
0
def isInteractivePosix():
    try:
        import posix
        tty = open("/dev/tty")
        tpgrp = posix.tcgetpgrp(tty.fileno())
        pgrp = posix.getpgrp()
        tty.close()
        return (tpgrp == pgrp)
    finally:
        return False
Example #3
0
 def get_running_fg_processes(self):
     total_procs = 0
     term_idx = 0
     for page_index in range(self.get_tab_count()):
         terminals = self.get_terminals_for_tab(page_index)
         for terminal in terminals:
             fdpty = terminal.get_pty()
             term_pid = terminal.get_pid()
             fgpid = posix.tcgetpgrp(fdpty)
             if not (fgpid == -1 or fgpid == term_pid):
                 total_procs += 1
             term_idx += 1
     return total_procs
Example #4
0
 def get_running_fg_processes(self):
     total_procs = 0
     term_idx = 0
     for page_index in range(self.get_tab_count()):
         terminals = self.get_terminals_for_tab(page_index)
         for terminal in terminals:
             fdpty = terminal.get_pty()
             term_pid = terminal.get_pid()
             fgpid = posix.tcgetpgrp(fdpty)
             if not (fgpid == -1 or fgpid == term_pid):
                 total_procs += 1
             term_idx += 1
     return total_procs
Example #5
0
 def get_running_fg_processes(self):
     """Get the number processes for each terminal/tab. The code is taken
     from gnome-terminal.
     """
     total_procs = 0
     term_idx = 0
     for terminal in self.term_list:
         fdpty = terminal.get_pty()
         term_pid = self.pid_list[term_idx]
         fgpid = posix.tcgetpgrp(fdpty)
         if not (fgpid == -1 or fgpid == term_pid):
             total_procs += 1
         term_idx += 1
     return total_procs
Example #6
0
def is_interactive():
    '''Return true if run from an interactive session.'''
    try:
        tty = open('/dev/tty')

        tpgrp = posix.tcgetpgrp(tty.fileno())
        pgrp  = posix.getpgrp()

        tty.close()

        return (tpgrp == pgrp)

    except IOError:
        return False
Example #7
0
 def get_running_fg_processes_tab(self, index):
     total_procs = 0
     for terminal in self.get_terminals_for_tab(index):
         fdpty = terminal.get_pty()
         term_pid = terminal.get_pid()
         try:
             fgpid = posix.tcgetpgrp(fdpty)
             if not (fgpid == -1 or fgpid == term_pid):
                 total_procs += 1
         except OSError:
             log.debug("Cannot retrieve any pid from terminal %s, looks like it is already dead",
                       index)
             return 0
     return total_procs
Example #8
0
 def get_running_fg_processes_count_page(self, index):
     total_procs = 0
     for terminal in self.get_terminals_for_page(index):
         fdpty = terminal.get_pty().get_fd()
         term_pid = terminal.pid
         try:
             fgpid = posix.tcgetpgrp(fdpty)
             log.debug("found running pid: %s", fgpid)
             if fgpid not in (-1, term_pid):
                 total_procs += 1
         except OSError:
             log.debug(
                 "Cannot retrieve any pid from terminal %s, looks like it is already dead",
                 index)
             return 0
     return total_procs
Example #9
0
 def get_running_fg_processes_count_page(self, index):
     total_procs = 0
     for terminal in self.get_terminals_for_page(index):
         pty = terminal.get_pty()
         if not pty:
             continue
         fdpty = pty.get_fd()
         term_pid = terminal.pid
         try:
             fgpid = posix.tcgetpgrp(fdpty)
             log.debug("found running pid: %s", fgpid)
             if fgpid not in (-1, term_pid):
                 total_procs += 1
         except OSError:
             log.debug(
                 "Cannot retrieve any pid from terminal %s, looks like it is already dead", index
             )
             return 0
     return total_procs
Example #10
0
 def is_foreground():
   tpgrp = posix.tcgetpgrp(posix_tty_fd)
   pgrp  = posix.getpgrp()
   return tpgrp == pgrp