Skip Menu |
 

This queue is for tickets about the Win32-Process CPAN distribution.

Report information
The Basics
Id: 30573
Status: new
Priority: 0/
Queue: Win32-Process

People
Owner: Nobody in particular
Requestors: terry.glanfield [...] printsoft.com
mathieu [...] closetwork.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: Win32::Process::Create() - No file handle inheritance in a service
Date: Thu, 8 Nov 2007 11:50:52 GMT
To: bug-libwin32 [...] rt.cpan.org
From: Terry Glanfield <terry.glanfield [...] printsoft.com>
Download (untitled) / with headers
text/plain 847b
The appended patch to Process/Process.hpp fixes an issue with windows services whereby the file handles weren't being inherited into the new process. The same program run as a console application would work as expected. The patch would appear to be a noop as this is standard behaviour but is clearly doing something extra when used as part of a service. I don't have a small test-suite to demonstrate it. The application is using POE and PerlSvc. ActivePerl 5.8.8 Build 822 ActiveState Perl Dev Kit 7.0.0 Build 277058 to build the service. 38d37 < st.dwFlags = 0; 42a42,49 Show quoted text
> if (Inherit) { > st.dwFlags = STARTF_USESTDHANDLES; > st.hStdInput = GetStdHandle(STD_INPUT_HANDLE); > st.hStdOutput = GetStdHandle(STD_OUTPUT_HANDLE); > st.hStdError = GetStdHandle(STD_ERROR_HANDLE); > } else { > st.dwFlags = 0; > }
Download (untitled) / with headers
text/plain 1.5k
When running as a service (using perlsvc), if the service opens STDIN, STDOUT or STDERR to some file, any process ran using Win32::Process will not inherit the file handles. This bug previously reported it, and offered a patch: https://rt.cpan.org/Public/Bug/Display.html?id=30573 Here's how to reproduce it. Create a directory, download this snippet into the file testservice.pl http://pastebin.com/m78325af Then this snippet into job.pl http://pastebin.com/m3dc56344 Compile testservice.pl as a service in a console window: perlapp --force job.pl perlsvc --force testservice.pl Now, if you run testservice.exe directly: testservice.exe and you look into the newly created job.log file, you should see this: Wed Mar 25 12:58:37 2009: [from service] test stdout. Fileno:1 Wed Mar 25 12:58:37 2009: [from service] test stderr. Fileno:2 Wed Mar 25 12:58:37 2009: Starting Win32::Process Next, you should see two lines from the process. job.exe Win32::Process: Testing stderr. job.exe Win32::Process: Testing stdout. Over and over again. But if you start it as a service: testservice.exe --install auto you will see this in job.log, missing the output from the job.exe. Wed Mar 25 12:58:37 2009: [from service] test stdout. Fileno:1 Wed Mar 25 12:58:37 2009: [from service] test stderr. Fileno:2 Wed Mar 25 12:58:37 2009: Starting Win32::Process Next, you should see two lines from the process. In testservice.log, I open STDOUT and STDERR towards job.log, right before starting job.exe, So job.exe's output should be in job.log, but that doesn't work with a service, for some reason.


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.