Skip to content

Commit bc28d61

Browse files
authored
Merge pull request #5789 from mueslo/patch-1
Fix _check_pid_win32
2 parents 2b47644 + cd91bd1 commit bc28d61

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

notebook/utils.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,13 +284,15 @@ def check_version(v, check):
284284
return True
285285

286286

287-
# Copy of IPython.utils.process.check_pid:
288-
289287
def _check_pid_win32(pid):
290288
import ctypes
291289
# OpenProcess returns 0 if no such process (of ours) exists
292290
# positive int otherwise
293-
return bool(ctypes.windll.kernel32.OpenProcess(1,0,pid))
291+
handle = ctypes.windll.kernel32.OpenProcess(1,0,pid)
292+
if handle:
293+
# the handle must be closed or the kernel process object won't be freed
294+
ctypes.windll.kernel32.CloseHandle( handle )
295+
return bool(handle)
294296

295297
def _check_pid_posix(pid):
296298
"""Copy of IPython.utils.process.check_pid"""

0 commit comments

Comments
 (0)