[Mono-list] Sending POSIX signals to external processes

Miguel de Icaza miguel@ximian.com
Tue, 27 Jul 2004 19:41:52 -0400


> I'm writing a C# program with Mono.  I start an external program with
> System.Diagnostics.Process.  In some situations (triggered by the user), I
> want to kill the process in as friendly a manner as possible.  Using
> Process.Kill is the obvious (and only) choice, but this is far too brutal; 
> the process is not given a chance to clean up after itself, so it leaves a
> lock file.  I know though experiments with kill(1) that this program, if
> sent a SIGTERM, will take care of cleaing up after itself.  Is there any
> way at all to send such a signal?  I suppose I could start yet another
> Process that runs 'kill -s SIGTERM ...', but this seems a little dirty.

You can use the Mono.Posix library, and then call Syscall.kill (pid, sig)