http://www.perlmonks.org?node_id=1030318


in reply to Re: Windows process suspend
in thread Windows process suspend

the documentation has given this line:

Suspend(@Handles); or Suspend($Handle);

So what am I exactly doing wrong?

One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. -Elbert Hubbard

Replies are listed 'Best First'.
Re^3: Windows process suspend
by roboticus (Chancellor) on Apr 24, 2013 at 10:09 UTC

    gautamparimoo:

    You want to kill specific processes. Each process ID is a number referring to a job. So you need to determine which process number you want to kill. It looks like you have things in hand to that point. But when you get the handles for the threads, you've got a bug. Since GetHandles returns a *list* of handles, you'll need to do something like:

    use strict; use warnings; use Win32::Process::Kill; my $pids = $ARGV[0]; # Get *all* the handles returned my @handles = GetHandle($pids); print scalar(@handles), " handles returned\n"; # We'll just suspend the first one: my $handle = $handles[0]; SuspendProcess($handle);

    Note: I'm on a linux box right now, so I can't test things out at the moment, but after reviewing the docs, that's what I'm expecting.

    ...roboticus

    When your only tool is a hammer, all problems look like your thumb.

      I think the problem is with use Win32::Process::Kill; as if i print anything after it that does not get printed and it crashes.Secondly in the documents its shown as:

      @Handles = GetHandle(@pids); or ($handle) = GetHandle($pid);

      So I cannot make out the problem. If anybody on Windows please explain?

      One machine can do the work of fifty ordinary men. No machine can do the work of one extraordinary man. -Elbert Hubbard

        Are you saying you will get a crash if you just do this:

        use Win32::Process::Kill; print "I am OK\n";

        Cheers,
        R.

        Pereant, qui ante nos nostra dixerunt!