#6146: emulate Unix.kill with signal = Sys.sigkill under Windows.

git-svn-id: http://caml.inria.fr/svn/ocaml/trunk@14059 f963ae5c-01c2-4b8c-9fe0-0dff7051ff02
master
Alain Frisch 2013-09-03 13:10:56 +00:00
parent cb146ec66b
commit e972313976
4 changed files with 19 additions and 2 deletions

View File

@ -17,6 +17,7 @@ Bug fixes:
Standard library:
- PR#4986: add List.sort_uniq and Set.of_list
- PR#6148: speed improvement for Buffer (patch by John Whitington)
- PR#6146: support "Unix.kill pid Sys.sigkill" under Windows
Features wishes:
- PR#4243: make the Makefiles parallelizable

View File

@ -677,7 +677,8 @@ val lockf : file_descr -> lock_command -> int -> unit
val kill : int -> int -> unit
(** [kill pid sig] sends signal number [sig] to the process
with id [pid]. *)
with id [pid]. Under Windows, only the [Sys.sigkill] signal
is emulated. *)
type sigprocmask_command =
SIG_SETMASK

View File

@ -82,3 +82,8 @@ static int win_has_console(void)
return 1;
}
}
CAMLprim value win_terminate_process(value v_pid)
{
return (Val_bool(TerminateProcess((HANDLE) Long_val(v_pid), 0)));
}

View File

@ -374,7 +374,17 @@ type lock_command =
| F_TRLOCK
external lockf : file_descr -> lock_command -> int -> unit = "unix_lockf"
let kill pid signo = invalid_arg "Unix.kill not implemented"
external terminate_process: int -> bool = "win_terminate_process"
let kill pid signo =
if signo <> Sys.sigkill then
invalid_arg "Unix.kill"
else
if not (terminate_process pid) then
raise(Unix_error(ESRCH, "kill", ""))
(* could be more precise *)
type sigprocmask_command = SIG_SETMASK | SIG_BLOCK | SIG_UNBLOCK
let sigprocmask cmd sigs = invalid_arg "Unix.sigprocmask not implemented"
let sigpending () = invalid_arg "Unix.sigpending not implemented"