Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions nmap3/nmap3.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ def __init__(self, path:str=''):
self.parser = NmapCommandParser(None)
self.raw_output = None
self.as_root = False
self.pid_callback = None

def require_root(self, required=True):
"""
Expand Down Expand Up @@ -260,6 +261,11 @@ def run_command(self, cmd, timeout=None):
stdout=subprocess.PIPE,
stderr=subprocess.PIPE
)
if self.pid_callback is not None:
try:
self.pid_callback(sub_proc.pid)
except Exception:
pass
try:
output, errs = sub_proc.communicate(timeout=timeout)
except Exception as e:
Expand Down Expand Up @@ -538,6 +544,11 @@ async def run_command(self, cmd, timeout=None):
stdout=self.stdout,
stderr=self.stderr
)
if self.pid_callback is not None:
try:
self.pid_callback(process.pid)
except Exception:
pass

try:
data, stderr = await process.communicate()
Expand Down