On Fri, 2012-10-05 at 11:20 +0100, Ru Vuott wrote:
> ...this is a possible way:
>
> ********************
> Public Sub Button1_Click()
>
> Dim s1, s2, pid As String
>
>
> s1 = InputBox("Insert the program name (<B>without</b> its extension
> .gambas):")
>
>
> For Each pid In Dir("/proc")
>
> If Exist("/proc/" & pid & "/cmdline") Then
>
> s2 = File.Load("/proc/" & pid & "/cmdline")
>
> If s2 Like "*" & s1 & ".gambas*" Then
> Shell "kill " & pid
> Exit
> Endif
>
> Endif
>
> Next
>
> End
>
> *******************
>
> bye
> vuotttt
>
>
>
Even that is risky, because if you have more than one instance of the
same executable running .. you will send a SIGTERM to all of them.
It is really much better to use a properly structured signal handler
within the project that can respond to SIGs and react appropriately and
if required close down in an orderly manner. Note that this not a
simple answer, even postgresql to date still has the warning "don't kill
the postmaster!"
( Hi Benoit :-) hint hint gb.signal hint hint...)
Oh! and a final comment generally within this thread. (IMO)
Never try to "kill" other processes from within a process. Much too
messy and they may come back as zombies and do the same thing to you.
"kill"ing is for humans to do, not programs (there could be a corollary
of one of Asimovs laws there, possibly?)
B
------------------------------------------------------------------------------
Don't let slow site performance ruin your business. Deploy New Relic APM
Deploy New Relic app performance management and know exactly
what is happening inside your Ruby, Python, PHP, Java, and .NET app
Try New Relic at no cost today and get our sweet Data Nerd shirt too!
http://p.sf.net/sfu/newrelic-dev2dev
_______________________________________________
Gambas-user mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/gambas-user