-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Description
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.