Skip to content

Commit 0920200

Browse files
committed
fix: avoid no child pid kill
1 parent 50d1fd1 commit 0920200

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

bigcodebench/eval/utils.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,8 +228,11 @@ def safe_exec(*args, **kwargs):
228228
# Wait for a short time to see if the process terminates
229229
for _ in range(10): # Wait up to 1 second
230230
time.sleep(0.1)
231-
if os.waitpid(pid, os.WNOHANG) != (0, 0):
232-
break
231+
try:
232+
# Check if the process has terminated
233+
os.kill(pid, 0)
234+
except ProcessLookupError:
235+
break # Process has terminated
233236
else:
234237
# If the process didn't terminate, try SIGKILL
235238
os.kill(pid, signal.SIGKILL)

0 commit comments

Comments
 (0)