Kill external process
-
Hi,
I'm running some external processes from my plugin.
Since they can run rather long, I would like to offer a user possibility to abort started external process. Is there some elegant way to do it in SU?Only way I've found for now is when user press some button, I call:
taskkill /f /im my_program.exeor
tskill my_program(since no idea how to get PID of the external process from my Plugin, I use image name or exectuable name).
BTW: I'm running process with UI.openURL() and batch_file.
I'm using SU 8 in Windows 7 operating system.Thanks in advance,
Marija -
You can use tlist.exe (XP) or tasklist.exe (Vista/Win7) to check when the SU process ended.
(The catch is that XP Home doesn't come with tlist.exe, it must be ... installed separately*. It comes installed standard on XP Pro, or Win Server 2003+.
- is referring to the separate "Support Tools" installer on the Windows install CD.
And.. I do not know what the equivalent is on OSX.
-
Thanks Dan,
For now plugin is only Windows oriented so these tasklist or tlist would do the job for listing running processes
-
Hi,
I've implemented killing of external process (which is started by UI.openURL) with next method:
-call 'tasklist' - to check is process is still running and to get process PID
-then in plugin Process.kill("KILL",PID)This approach works, but I also want to inform object that started external process that process is killed (so some timers are stopped).
I though to implement that with signals:
-after process is killed I send signal "USR1" for example
-and I trap the same signal in class that started process - and then stop timers.Problem is that Sketchup doesn't recognize "USR1" signal.
I've tried in Ruby console:
Signal.list.keys.join ", " TERM, SEGV, KILL, EXIT, INT, FPE, ABRT, ILLBut none of these signals are the ones I need, I need some custom user defined signal for my plugin.
Is the thing I need possible, and how to do it in Ruby/Sketchup?
Thanks in advance,
Marija -
Just pass a reference of the timer id object, to the method that kills the process, and call
UI.stop_timer(tid)from that method, after it is verified, that the process is dead. -
OR.. in object 1, write a callback method that is called from the killing object:
def deceased UI.stop_timer(@tid) # any other post death cleanup endAssumes you save a reference to the timer id, in object 1, when you started the timer, like:
@tid = UI.start_timer(delay,true) { # code block } -
Thanks Dan,
Your suggestion to write callback that is called from killing object, was very useful idea - and makes nice readable code.
Much better idea then various signals I planned to use before.
Thanks again,
Marija
Hello! It looks like you're interested in this conversation, but you don't have an account yet.
Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.
With your input, this post could be even better π
Register LoginAdvertisement