Skip to content

Commit

Permalink
Improve session detection logic
Browse files Browse the repository at this point in the history
Process.terminal() returns the path to the terminal attached to the
process, if one exists. This will include most processes launched
interactively, not just processes that represent sessions. This
implements a new heuristic, in which a process is a session if it has a
terminal attached and either somehow has no parent or its parent has a
different terminal attached. This heuristic is probably not foolproof,
but should be sufficient for the majority of cases.
  • Loading branch information
elyscape committed Dec 13, 2018
1 parent 1932c5f commit cd7288a
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions tracer/resources/processes.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,8 +245,12 @@ def is_interpreted(self):

@property
def is_session(self):
if self.terminal() is not None:
return True
terminal = self.terminal()
if terminal is None:
return None
parent = self.parent()
if parent is None or terminal != parent.terminal():
return True

@property
def real_name(self):
Expand Down

0 comments on commit cd7288a

Please sign in to comment.