Skip to content

Commit 915388a

Browse files
committed
Merge branch 'issue5'
2 parents 1de2273 + 842864d commit 915388a

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

libnmap/process.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def __init__(self, targets="127.0.0.1",
9696
self.__summary = ''
9797
self.__stdout = ''
9898
self.__stderr = ''
99+
self.initial_threads = 0
99100

100101
def _run_init(self):
101102
"""
@@ -213,6 +214,7 @@ def stream_reader(thread_stdout, io_queue):
213214
stdout=subprocess.PIPE,
214215
stderr=subprocess.PIPE,
215216
bufsize=0)
217+
self.initial_threads = threading.active_count()
216218
Thread(target=stream_reader, name='stdout-reader',
217219
args=(self.__nmap_proc.stdout,
218220
self.__io_queue)).start()
@@ -240,7 +242,7 @@ def __wait(self):
240242
"""
241243
thread_stream = ''
242244
while (self.__nmap_proc.poll() is None or
243-
threading.active_count() > 1 or
245+
threading.active_count() != self.initial_threads or
244246
not self.__io_queue.empty()):
245247
try:
246248
thread_stream = self.__io_queue.get_nowait()
@@ -484,7 +486,6 @@ def mycallback(nmapscan=None):
484486
print("Progress: {0}% - ETC: {1}").format(nmapscan.progress,
485487
nmapscan.etc)
486488

487-
#nm = NmapProcess("scanme.nmap.org", options="-sV",
488489
nm = NmapProcess("localhost", options="-sV",
489490
event_callback=mycallback)
490491
rc = nm.run()

0 commit comments

Comments
 (0)