Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

improve signal handling #399

Open
karmacoma-eth opened this issue Oct 30, 2024 · 0 comments
Open

improve signal handling #399

karmacoma-eth opened this issue Oct 30, 2024 · 0 comments
Labels
enhancement New feature or request

Comments

@karmacoma-eth
Copy link
Collaborator

when halmos is waiting on a solver and we type ctrl+c, we don't want the current solver to get the signal, we want halmos to get the signal and interrupt the run cleanly (killing already spawned solvers).

Something like this:

import os
import subprocess
import sys
import atexit

# Create process with different flags based on platform
if os.name == 'nt':  # Windows
    proc = subprocess.Popen(
        ["jsi", "--full-run", "examples/unsat_div.smt2"],
        creationflags=subprocess.CREATE_NEW_PROCESS_GROUP
    )
else:  # Unix-like
    os.setpgrp()
    proc = subprocess.Popen(
        ["jsi", "--full-run", "examples/unsat_div.smt2"],
        preexec_fn=os.setpgrp,
        start_new_session=True
    )

print(f"started {proc.pid=}")
atexit.register(lambda: proc.kill())
sys.exit(42)

Explanation: all processes in the foreground process group of the current session receive the signal, so we want the external solvers to run in a different session and process group, in order to make sure that halmos itself orchestrates external processes correctly.

@karmacoma-eth karmacoma-eth added the enhancement New feature or request label Oct 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant