Ask a Question related to PERL Modules, Design and Development.
-
chacallot #1
Win32::Process, SetProcessAffinityMask for an existing process =perl crash
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.
chacallot Guest
-
Win32::Process Kill Process in Windows ME
Hello, I want to kill a Process in Windows ME, which I have started. I have executed the following lines in XP and it works. I execute this in... -
Q: Win32::Process::Info
Hello, Does anyone have experience with this Modul? How can I make it work to get the CPU-Usage in % for a specific process ID? Or is there an... -
Win32::Process::Info and CreationDate
I'm writing a script to check for processes running longer than 5 minutes. When I return the CreationDate I get something like 1075306356. I'm... -
LOST - Win32::Process
Hi all, I am new and am lost with Win32::Process stuff. I want on perl script to start a process, then another perl script to terminate the... -
Understaing Win32::Process::Create
I am trying to use a perl program to spawn about 10 other perl programs. I was using the Win32::Process module with no sucess. I was creating the... -
Sisyphus #2
Re: Win32::Process, SetProcessAffinityMask for an existing process = perl crash
"chacallot" <chachallot@free.fr>
..That works fine for me on Windows2000 using MinGW-built perl 5.8.8 and>
> 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;
> -------------------
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
Sisyphus Guest
-
Reinhard Pagitsch #3
Re: Win32::Process, SetProcessAffinityMask for an existing process= perl crash
chacallot wrote:
The Problem is in the C/C++ source code. It uses a pointer to the> 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..
>
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
Reinhard Pagitsch Guest
-
Thomas Kratz #4
Re: Win32::Process, SetProcessAffinityMask for an existing process= perl crash
Reinhard Pagitsch wrote:
[ about Win32::Process::SetProcessAffinityMask crashing perl]> chacallot wrote:
Could you please elaborate or provide a patch? As I read it (which could> 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.
of course be wrong), your statement suggests that there is a
'SetProcessAffinityMask' outside of kernel32.dll.
Thomas
--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>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^.-
Thomas Kratz Guest
-
Reinhard Pagitsch #5
Re: Win32::Process, SetProcessAffinityMask for an existing process= perl crash
Hello Thomas,
Thomas Kratz wrote:I think you missunderstood what I wrote. What I have done is not using> 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.
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
Reinhard Pagitsch Guest
-
Thomas Kratz #6
Re: Win32::Process, SetProcessAffinityMask for an existing process= perl crash
Hello Reinhard,
Reinhard Pagitsch wrote:Yes, I was almost sure I did :-)> I think you missunderstood what I wrote.
Ah, I see. I don't understand why the LoadLibrary is done at all. Every> 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);
extension is linked against kernel32.lib anyway, which results in the
functions being called dynamically through kernel32.dll.
Thanks,
Thomas
--
$/=$,,$_=<DATA>,s,(.*),$1,see;__END__
s,^(.*\043),,mg,@_=map{[split'']}split;{#>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^.-
Thomas Kratz Guest
-
chacallot@gmail.com #7
Re: Win32::Process, SetProcessAffinityMask for an existing process = perl crash
Thx for your answers.
Emailed info about this thread to the module author.
Hope he'll be able to notice it in all the spam he's probably getting.
His email is an @activestate.com. Lets see how active those are...
Regards,
Chacallot.
chacallot@gmail.com Guest



Reply With Quote

