Skip to content

Commit

Permalink
Use the correct pipe identifiers on both Linux and OS X
Browse files Browse the repository at this point in the history
  • Loading branch information
walles committed Jul 3, 2016
1 parent 49759c5 commit f00a365
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
18 changes: 12 additions & 6 deletions px/px_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,19 @@ def device_number(self):
return number

def fifo_id(self):
if self.name and '/' in self.name:
# This FIFO is named with a proper path
return self.name
if self.inode is not None:
# On Linux, pipes are presented by lsof as FIFOs. They have unique-
# per-pipe inodes, so we use them as IDs.
return self.inode

if self.type == 'FIFO' and self.name == 'pipe':
# This is just a label that can be shared by several pipes on Linux,
# we can't use it to identify a pipe.
return None

# If the FIFO doesn't have '/' in its name it's not named. Try
# identifying the FIFO by inode instead.
return self.inode
# On OS X, pipes are presented as PIPEs and lack inodes, but they
# compensate by having unique names.
return self.name

def get_endpoints(self):
"""
Expand Down
2 changes: 1 addition & 1 deletion px/px_ipc_map.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def _create_mapping(self):
continue

if file.type == 'FIFO' and not file.fifo_id():
# FIFO with neither name nor inode info
# Unidentifiable FIFO, just ignore this
continue

self.add_ipc_entry(unknown, file)
Expand Down

0 comments on commit f00a365

Please sign in to comment.