IWETHEY v. 0.3.0 | TODO
1,095 registered users | 0 active users | 0 LpH | Statistics
Login | Create New User
IWETHEY Banner

Welcome to IWETHEY!

New Windows killing
I needed to have a windows process timeout.
If it spwaned any children, I need to hunt them
down and kill them. But I did not want to kill
the master process, since it was a batch file
that cleaned up, copying logs around, etc.

I did not stumble over anything pre-written, so
I came up with this:

\n\nif ((time - $START_TIMES{$id}) > $CURRENT_CHILDREN_TIMEOUT{$id}){\n   hunt_down_and_kill_children($id,undef);\n}\n\nsub hunt_down_and_kill_children{\n\tmy $pid = shift;\n\tmy $subs = shift;\n\n\tmy $top_level = 0;\n\n\n\tif (!defined($subs)){\n\t\tmy $pi = Win32::Process::Info->new();\n\t\tmy %subs = $pi->Subprocesses();\n\t\t$subs = \\%subs;\n\t\t$top_level++;\n\t}\n \n\tif (defined($subs->{$pid}) && exists($subs->{$pid})){\n\t\tforeach my $kid (@{$subs->{$pid}}){\n\t\t\thunt_down_and_kill_children($kid,$subs);\n\t\t}\n\t}\n\n\t#\n\t# Do not kill the master batch file since\n\t# it is responsibile for copying files around\n\t# and cleanup.\n\t#\n\tunless ($top_level){\n\t\tWin32::Process::KillProcess($pid,99);\n\t}\n}\n\n


Did I miss something already built to do this?
Is this method dangerous?
New Extra threads showing up
When I invoke that logic, the Process Explorer shows a bunch of keys and 4 new threads showing up in my perl.exe.

I toss another timeout task, and no more show up.

I toss another task 10 minutes later, have it timeout and
abort, and another thread shows up.

I can't get it to consume
anymore.

This is probably bad.

Will I eventually consume all the threads on the box?
     Windows killing - (broomberg) - (1)
         Extra threads showing up - (broomberg)

This is immediately dreadful.
63 ms