Skip to content

Commit 6afac14

Browse files
committed
Use named pipe to terminate MiniZinc on Windows
Uses the same approach that the MiniZinc IDE uses to terminate MiniZinc on Windows, by writing to a named pipe created by MiniZInc. Fixes #191
1 parent 45fabec commit 6afac14

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

src/minizinc/instance.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -661,9 +661,9 @@ async def solutions(
661661
# an unexpected Python exception occurred
662662
# First, terminate the process
663663
if sys.platform == "win32":
664-
import signal
665-
666-
proc.send_signal(signal.CTRL_C_EVENT)
664+
with open(f"\\\\.\\pipe\\minizinc-{proc.pid}", mode="w") as named_pipe:
665+
# Trigger MiniZinc termination
666+
named_pipe.write("")
667667
else:
668668
proc.terminate()
669669
_ = await proc.wait()

0 commit comments

Comments
 (0)