tags:

views:

183

answers:

1

I have a Perl script running that acts like a service, one of the things I do with it is use it to spawn other processes. Some of these processes are executables and some are perl scripts.

At times I want to set the processor affinity on some these processes. I use SetProcessAffinityMask to do this, for the executables everything works as expected. For perl scripts doing this crashes my Perl service. I am running activestate perl 5.8.8, I have done some googling and have found one other thread that mentions a similar issue as to what I am seeing and the consensus of that thread seems to be with the way Perl was compiled. Any ideas or suggestions?


I have pinpointed the issue down to the actual Perl I am running. It seems that ActiveState Perl 5.8.8 has an issue with SetProcessAffinityMask(). I uninstalled 5.8.8 and installed 5.10.1, used the same exact code and everything worked as expected.


I am using Win32::Process:Create and utilizing the Win32::Process:setAffinityMask

A: 

That sample code (which is somebody else's code, right?) is crap -- passing a hard-coded process ID to Win32::Process::Open is almost certain to fail. How are you using the methods from Win32::Process?

Also the doc for Win32::Process notes:

    $ProcessObj->SetProcessAffinityMask($processAffinityMask)
        Set the process affinity mask. Only available on Windows NT.

but that might just mean that the documentation is outdated.

use strict;
use Win32::Process;
use Win32;
my $obj;
my $pid=2216;
my $iflags;
Win32::Process::Open($obj,$pid,$iflags) or die;
my $processAffinityMask;
my $systemAffinityMask;
$obj->GetProcessAffinityMask($processAffinityMask, $systemAffinityMask) or die;
$obj->SetProcessAffinityMask($processAffinityMask) or die;
mobrule