@@ -66,7 +66,7 @@ def __init__(self, interface=None, channel=None, target_bssid=None,
6666
6767 # Generate output file if not provided
6868 if output_file is None :
69- self .output_file = Configuration .temp () + 'hcxdumptool_capture.pcapng'
69+ self .output_file = os . path . join ( Configuration .temp (), 'hcxdumptool_capture.pcapng' )
7070 else :
7171 self .output_file = output_file
7272
@@ -122,7 +122,11 @@ def __enter__(self):
122122
123123 # Start the process
124124 self .proc = Process (command , devnull = False )
125- self .pid = self .proc .pid .pid # Get the actual PID from the Popen object
125+ # Get the actual PID safely from the Popen object
126+ if self .proc and hasattr (self .proc , 'pid' ) and self .proc .pid and hasattr (self .proc .pid , 'pid' ):
127+ self .pid = self .proc .pid .pid
128+ else :
129+ self .pid = None
126130
127131 # Give it a moment to start
128132 time .sleep (1 )
@@ -141,8 +145,11 @@ def __exit__(self, exc_type, exc_val, exc_tb):
141145 time .sleep (0.5 )
142146
143147 # Force kill if still running
144- if self .proc .poll () is None :
145- os .kill (self .pid , signal .SIGKILL )
148+ if self .proc .poll () is None and self .pid is not None :
149+ try :
150+ os .kill (self .pid , signal .SIGKILL )
151+ except ProcessLookupError :
152+ pass # Process already exited
146153 except Exception as e :
147154 from ..util .logger import log_debug
148155 log_debug ('HcxDumpTool' , f'Kill process error: { e } ' )
@@ -239,7 +246,7 @@ def __init__(self, interface=None, output_file=None):
239246
240247 # Generate output file if not provided
241248 if output_file is None :
242- self .output_file = Configuration .temp () + 'passive_pmkid.pcapng'
249+ self .output_file = os . path . join ( Configuration .temp (), 'passive_pmkid.pcapng' )
243250 else :
244251 self .output_file = output_file
245252
@@ -262,7 +269,11 @@ def __enter__(self):
262269
263270 # Start the process
264271 self .proc = Process (command , devnull = False )
265- self .pid = self .proc .pid .pid # Get the actual PID from the Popen object
272+ # Get the actual PID safely from the Popen object
273+ if self .proc and hasattr (self .proc , 'pid' ) and self .proc .pid and hasattr (self .proc .pid , 'pid' ):
274+ self .pid = self .proc .pid .pid
275+ else :
276+ self .pid = None
266277
267278 # Give it a moment to start
268279 time .sleep (1 )
@@ -281,8 +292,11 @@ def __exit__(self, exc_type, exc_val, exc_tb):
281292 time .sleep (0.5 )
282293
283294 # Force kill if still running
284- if self .proc .poll () is None :
285- os .kill (self .pid , signal .SIGKILL )
295+ if self .proc .poll () is None and self .pid is not None :
296+ try :
297+ os .kill (self .pid , signal .SIGKILL )
298+ except ProcessLookupError :
299+ pass # Process already exited
286300 except Exception as e :
287301 from ..util .logger import log_debug
288302 log_debug ('HcxDumpToolPassive' , f'Kill process error: { e } ' )
0 commit comments