|
|
|
|
|
Posted by chacallot on May 7, 2006, 6:22 pm
Please log in for more thread options
Hi!
Was planning to use Win32::Process to set the ProcessAffinityMask of
some processes but this lead to pure and simple crash of perl.exe.
This is not a credential problem as I can set the process affinity if I
spawn a "process.exe" command to set the affinity.
Also, the process affinity is correctly set to the expected value...
Seems the crash occurs just after.
Here is a sample code causing a perl.exe crash (for example using
activeperl 5.6 or 5.8 (latest) on Windows 2000, XP or 2003) :
------------------
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;
-------------------
I also experience strange behavior while using Win32::Daemon to make my
perl scripts act as an NT service (under Windows 2003 my script
unexpectedly says he receives SERVICE_STOP signals. And stops..).
Am feeling I should abandon perl to do system tasks on Windows systems.
Too bad cause I invested quite some time to get knowledgeable in perl...
And I must also improve in Java for weblogic stuff. So am not willing
to start learning yet another language like VB/.NET..
Rgds,
Chacallot.
|
|
Posted by Sisyphus on May 8, 2006, 3:48 am
Please log in for more thread options
.
>
> Here is a sample code causing a perl.exe crash (for example using
> activeperl 5.6 or 5.8 (latest) on Windows 2000, XP or 2003) :
> ------------------
> 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;
> -------------------
That works fine for me on Windows2000 using MinGW-built perl 5.8.8 and
MinGW-built perl 5.6, but like you, I find it crashes with ActiveState perl
when SetProcessAffinityMask() gets called.
I don't know why it crashes with perl built using a Microsoft compiler (also
crashes with my VC7-built perl), and yet causes no problem with MinGW-built
perl.
If you don't find the answer here I would try posting to
comp.lang.perl.misc - and if that fails, try the perl-win32-users mailing
list hosted by ActiveState.
Cheers,
Rob
|
|
Posted by Reinhard Pagitsch on May 9, 2006, 9:36 am
Please log in for more thread options
chacallot wrote:
> Hi!
>
> Was planning to use Win32::Process to set the ProcessAffinityMask of
> some processes but this lead to pure and simple crash of perl.exe.
>
> This is not a credential problem as I can set the process affinity if I
> spawn a "process.exe" command to set the affinity.
>
> Also, the process affinity is correctly set to the expected value...
> Seems the crash occurs just after.
>
> Here is a sample code causing a perl.exe crash (for example using
> activeperl 5.6 or 5.8 (latest) on Windows 2000, XP or 2003) :
> ------------------
> 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;
> -------------------
>
>
>
> I also experience strange behavior while using Win32::Daemon to make my
> perl scripts act as an NT service (under Windows 2003 my script
> unexpectedly says he receives SERVICE_STOP signals. And stops..).
>
> Am feeling I should abandon perl to do system tasks on Windows systems.
> Too bad cause I invested quite some time to get knowledgeable in perl...
> And I must also improve in Java for weblogic stuff. So am not willing
> to start learning yet another language like VB/.NET..
>
The Problem is in the C/C++ source code. It uses a pointer to the
function defined in kernel32.dll. I changed the source to use the
SetProcessAffinityMask API directly and now there is no crash.
So I suggest to ask the owner of the module to change it.
regards,
Reinhard
|
|
Posted by Thomas Kratz on May 10, 2006, 4:37 am
Please log in for more thread options
Reinhard Pagitsch wrote:
> chacallot wrote:
[ about Win32::Process::SetProcessAffinityMask crashing perl]
> The Problem is in the C/C++ source code. It uses a pointer to the
> function defined in kernel32.dll. I changed the source to use the
> SetProcessAffinityMask API directly and now there is no crash.
Could you please elaborate or provide a patch? As I read it (which could
of course be wrong), your statement suggests that there is a
'SetProcessAffinityMask' outside of kernel32.dll.
Thomas
--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*3),,mg,@_=mapsplit;{#>J~.>_an~>>e~......>r~
$_=$_[$%][$"];y,<~>^,-++-,?{$/=--$|?'"':#..u.t.^.o.P.r.>ha~.e..
'%',s,(.),$$/$1=1,,$;=$_}:/\w/?{y,_, ,,#..>s^~ht<._..._..c....
print}:y,.,,||last,,,,,,$_=$;;eval,redo}#.....>.e.r^.>l^..>k^.-
|
|
Posted by Reinhard Pagitsch on May 11, 2006, 5:37 am
Please log in for more thread options
Hello Thomas,
Thomas Kratz wrote:
> Reinhard Pagitsch wrote:
>> chacallot wrote:
>
> [ about Win32::Process::SetProcessAffinityMask crashing perl]
>
>> The Problem is in the C/C++ source code. It uses a pointer to the
>> function defined in kernel32.dll. I changed the source to use the
>> SetProcessAffinityMask API directly and now there is no crash.
>
> Could you please elaborate or provide a patch? As I read it (which could
> of course be wrong), your statement suggests that there is a
> 'SetProcessAffinityMask' outside of kernel32.dll.
I think you missunderstood what I wrote. What I have done is not using
LoadLibrary() to import SetProcessAffinityMask function with
GetProcAddress(). I used the (API?) function as described in the
Platform SDK:
BOOL SetProcessAffinityMask( HANDLE hProcess, DWORD_PTR
dwProcessAffinityMask);
The patch:
In the Process.hpp:
class cProcess
{
....
BOOL _SetProcessAffinityMask( DWORD dwProcessAffinityMask )
{
BOOL ret;
//if(pSetProcessAffinityMask)
ret = SetProcessAffinityMask( ph, dwProcessAffinityMask );
if(!ret) return GetLastError();
return ret;
//return FALSE;
}
...
};
(The original code is commented out with //.)
And in the Process.xs:
BOOL
SetProcessAffinityMask(cP,processAffinityMask)
cProcess *cP
DWORD processAffinityMask
CODE:
RETVAL = cP->_SetProcessAffinityMask(processAffinityMask);
OUTPUT:
RETVAL
Thats all, now I do not get a crash of my Perl v5.6.1.
regards,
Reinhard
|
| Similar Threads | Posted | | Win32::Process Kill Process in Windows ME | April 13, 2005, 1:49 am |
| Problem in using Win32::Process::Create | July 24, 2007, 6:25 am |
| Win32::Process::Create(vxsim) cmd line argument trouble | December 17, 2007, 9:05 am |
| Process syncronization in perl? | November 6, 2004, 5:10 pm |
| Getting the name of the process via the process ID | December 14, 2004, 7:14 am |
| fork process help needed | March 15, 2007, 8:56 pm |
| starting a background process via Net::SSH::W32Perl | September 7, 2004, 10:41 am |
| CPAN module validation process | July 19, 2007, 3:58 pm |
| kill process when file count reached,,. | July 1, 2008, 7:25 pm |
| How to write into existing Excel Spreadsheets? | July 13, 2004, 1:24 pm |
|
|
|
|