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

kill child processes when benchmarking is terminated with Ctrl-C #74

Open
dimlio opened this issue Feb 27, 2023 · 3 comments
Open

kill child processes when benchmarking is terminated with Ctrl-C #74

dimlio opened this issue Feb 27, 2023 · 3 comments
Labels
help wanted Extra attention is needed

Comments

@dimlio
Copy link
Contributor

dimlio commented Feb 27, 2023

Now when a benchmark hangs and I terminate it with Ctrl-C spawned processes remain running.

@hassila
Copy link
Contributor

hassila commented Mar 16, 2023

Agree, this is a bit irritating - it's a bit unclear how I can trap signals easily in the top level command plugin portably though, needs investigation.

@hassila hassila added the help wanted Extra attention is needed label Mar 16, 2023
@hassila
Copy link
Contributor

hassila commented Mar 17, 2023

I did a try on this, but it seems even with --disable-sandbox I can't send a signal to the child process, with sandbox I get EPERM and with sandbox disabled I get ESRCH (with the correct pid provided).

I basically did this (in benchmark command plugin, command tool and benchmark runner all the way):

  var childPid: pid_t = 0
...
                _ = signal(SIGINT, callback)
...
    typealias SignalCallbackType = @convention(c) (Int32) -> Void
    let callback: SignalCallbackType = { signalNumber in
        let result = kill(childPid, SIGINT)
        print("\(childPid) Errno \(errno), result \(result)")
        exit(0)
    }

I can get a printout so the signal handler is correctly installed, I just can't kill the child processes.

@hassila
Copy link
Contributor

hassila commented Mar 20, 2023

I filed this case too:

swiftlang/swift-package-manager#6307

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Development

No branches or pull requests

2 participants