in reply to Re^4: Read STDOUT from Win32::Job while process is running
in thread Read STDOUT from Win32::Job while process is running
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^6: Read STDOUT from Win32::Job while process is running
by syphilis (Archbishop) on Mar 11, 2012 at 23:40 UTC | |
by BrowserUk (Patriarch) on Mar 12, 2012 at 13:57 UTC | |
by syphilis (Archbishop) on Mar 12, 2012 at 21:56 UTC | |
by BrowserUk (Patriarch) on Mar 12, 2012 at 22:27 UTC | |
|
Re^6: SOLUTION: Read STDOUT from child process and kill process tree
by Dirk80 (Pilgrim) on Mar 12, 2012 at 16:40 UTC |