Well ... I investigated and investigated ... then investigated a bit more ... and still couldn't see what the problem was.
So I then gave up and posted to the ActiveState users list - and about half an hour later Mark Dootson replied with the explanation and solution.
Well done and thank you.++
Rather than requiring the Perl sources modification -- which might be needed by something somewhere -- adding the define before the inclusion of the Perl headers achieves the same thing in a self-contained way. I've also cleaned up a couple of the warnings -- though traded them for others in some cases, but I'm not sure there is a better way?
The result looks like this:
#define _WIN32_WINNT 0x0500
#include "EXTERN.h"
#include "perl.h"
#include "XSUB.h"
#include "ppport.h"
#ifndef JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE
#define JOB_OBJECT_LIMIT_KILL_ON_JOB_CLOSE 0x2000
#endif
int createJobObject( char *name ) {
HANDLE job;
JOBOBJECT_EXTENDED_LIMIT_INFORMATION jeli = { 0, };
jeli.BasicLimitInformation.LimitFlags = JOB_OBJECT_LIMIT_KILL_ON_J
+OB_CLOSE;
job = CreateJobObjectA( NULL, name );
SetInformationJobObject( job, 9, &jeli, sizeof(jeli) );
return (int)job;
}
int assignProcessToJobObject( int job, int pid ) {
HANDLE hProc = OpenProcess( PROCESS_SET_QUOTA |PROCESS_TERMINATE,
+0, pid );
return (int)AssignProcessToJobObject( (HANDLE)job, hProc );
}
int closeHandle( int handle ) {
return (int)CloseHandle( (HANDLE)handle );
}
MODULE = Win32::JobAdd PACKAGE = Win32::JobAdd
int
createJobObject (name)
char * name
int
assignProcessToJobObject (job, pid)
int job
int pid
int
closeHandle (handle)
int handle
Salient part of the build trace: JobAdd.c
JobAdd.xs(18) : warning C4311: 'type cast' : pointer truncation from '
+HANDLE' to 'int'
JobAdd.xs(24) : warning C4312: 'type cast' : conversion from 'int' to
+'HANDLE' of greater size
JobAdd.xs(28) : warning C4312: 'type cast' : conversion from 'int' to
+'HANDLE' of greater size
link -out:blib\arch\auto\Win32\JobAdd\JobAdd.dll -dll -nologo
+-nodefaultlib -debug -opt:ref,icf -ltcg ...
Creating library blib\arch\auto\Win32\JobAdd\JobAdd.lib and object
+blib\arch\auto\Win32\JobAdd\JobAdd.exp
With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
|