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

Implement kill -9 using TerminateProcess, or provide TerminateProcess #6146

Closed
vicuna opened this issue Aug 29, 2013 · 2 comments
Closed

Implement kill -9 using TerminateProcess, or provide TerminateProcess #6146

vicuna opened this issue Aug 29, 2013 · 2 comments
Assignees
Milestone

Comments

@vicuna
Copy link

vicuna commented Aug 29, 2013

Original bug ID: 6146
Reporter: Bardou
Assigned to: @alainfrisch
Status: closed (set by @xavierleroy on 2015-12-11T18:24:01Z)
Resolution: fixed
Priority: normal
Severity: feature
Platform: Windows
Target version: 4.02.0+dev
Category: otherlibs

Bug description

I implemented terminate_process like this:

#include <windows.h>

CAMLprim value o_terminate_process(value o_pid)
{
CAMLparam1(o_pid);
CAMLlocal1(o_result);

// The implementation of Unix.create_process returns the Handle as PID.
// Luckily this is exactly what we need.
HANDLE pid = (HANDLE) Long_val(o_pid);
BOOL result = TerminateProcess(pid, 0);
o_result = Val_bool(result);

CAMLreturn(o_result);
}

external terminate_process: int -> bool = "o_terminate_process"

I figured I might as well share the code. This could be used either to implement Unix.kill at least for signal SIGKILL. Or, a new function terminate_process could be provided. Just like create_process exists to simulate the Windows function CreateProcess using the Unix function fork, the terminate_process would exist to simulate the Windows function TerminateProcess using the Unix function kill.

@vicuna
Copy link
Author

vicuna commented Aug 30, 2013

Comment author: @alainfrisch

LexiFi's version has implemented exactly that (implementing partially Unix.kill for Sys.sigkill). Unless someone argues in favor of a dedicated terminate_process function, I'll commit a version of the "Unix.kill" proposal.

@vicuna
Copy link
Author

vicuna commented Sep 3, 2013

Comment author: @alainfrisch

Wish granted (commit 14059 on trunk).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants