Mailing list for all users of the OCaml language and system.
 help / color / mirror / Atom feed
* Patch: kill() undex win32
@ 2004-11-11 10:48 Wesley W. Terpstra
  2004-11-11 12:54 ` Wesley W. Terpstra
  0 siblings, 1 reply; 4+ messages in thread
From: Wesley W. Terpstra @ 2004-11-11 10:48 UTC (permalink / raw)
  To: caml-list

[-- Attachment #1: Type: text/plain, Size: 776 bytes --]

Good evening.

I think it would be useful if the win32 version of ocaml could at least
terminate child processes. I am not a windows expert at all, and I do not
own VC++ so I cannot test this patch (is there a free licence for it?).

However, from reading the MSDN [1] it seems that to kill a process, the
method to use is TerminateProcess and has been present since Win95. The
attached patch adds to ocaml-3.08.1 a simple version of kill which
terminates a process.

Could someone who has VC++ verify if it works?
Do others think that this functionality would be useful?
Could something like this be present in the next version of OCaml?

Thanks!

[1] http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dllproc/base/terminateprocess.asp

-- 
Wesley W. Terpstra

[-- Attachment #2: ocaml-win32-terminate.patch --]
[-- Type: text/plain, Size: 2865 bytes --]

diff -uN otherlibs/win32unix.orig/Makefile.nt otherlibs/win32unix/Makefile.nt
--- otherlibs/win32unix.orig/Makefile.nt	2004-05-30 10:17:06.000000000 +0200
+++ otherlibs/win32unix/Makefile.nt	2004-11-11 11:34:58.000000000 +0100
@@ -30,7 +30,7 @@
   mkdir.c open.c pipe.c read.c rename.c \
   select.c sendrecv.c \
   shutdown.c sleep.c socket.c sockopt.c startup.c stat.c \
-  system.c unixsupport.c windir.c winwait.c write.c
+  system.c unixsupport.c windir.c winwait.c winkill.c write.c
 
 # Files from the ../unix directory
 UNIX_FILES = access.c addrofstr.c chdir.c chmod.c cst2constr.c \
diff -uN otherlibs/win32unix.orig/unix.ml otherlibs/win32unix/unix.ml
--- otherlibs/win32unix.orig/unix.ml	2004-06-22 19:18:50.000000000 +0200
+++ otherlibs/win32unix/unix.ml	2004-11-11 11:40:45.000000000 +0100
@@ -385,7 +385,8 @@
   | F_TRLOCK
 
 external lockf : file_descr -> lock_command -> int -> unit = "unix_lockf"
-let kill pid signo = invalid_arg "Unix.kill not implemented"
+external kill : int -> int -> unit = "win_killpid"
+
 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"
diff -uN otherlibs/win32unix.orig/winkill.c otherlibs/win32unix/winkill.c
--- otherlibs/win32unix.orig/winkill.c	1970-01-01 01:00:00.000000000 +0100
+++ otherlibs/win32unix/winkill.c	2004-11-11 11:33:50.000000000 +0100
@@ -0,0 +1,33 @@
+/***********************************************************************/
+/*                                                                     */
+/*                           Objective Caml                            */
+/*                                                                     */
+/*   Pascal Cuoq and Xavier Leroy, projet Cristal, INRIA Rocquencourt  */
+/*                                                                     */
+/*  Copyright 1996 Institut National de Recherche en Informatique et   */
+/*  en Automatique.  All rights reserved.  This file is distributed    */
+/*  under the terms of the GNU Library General Public License, with    */
+/*  the special exception on linking described in file ../../LICENSE.  */
+/*                                                                     */
+/***********************************************************************/
+
+/* $Id: winwait.c,v 1.14 2002/06/07 09:49:41 xleroy Exp $ */
+
+#include <windows.h>
+#include <mlvalues.h>
+#include <alloc.h>
+#include <memory.h>
+#include "unixsupport.h"
+#include <sys/types.h>
+
+CAMLprim value win_killpid(value sig, value vpid_req)
+{
+  /* we ignore the passed signal */
+  HANDLE pid_req = (HANDLE) Long_val(vpid_req);
+
+  if (! TerminateProcess(pid_req, 0x80)) {
+    win32_maperr(GetLastError());
+    uerror("killpid", Nothing);
+  }
+  return Val_unit;
+}

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2004-11-12  1:07 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-11-11 10:48 Patch: kill() undex win32 Wesley W. Terpstra
2004-11-11 12:54 ` Wesley W. Terpstra
2004-11-11 23:42   ` [Caml-list] " Christopher A. Watford
2004-11-12  1:07     ` Wesley W. Terpstra

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox