Skip Menu |
 

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

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

People
Owner: Nobody in particular
Requestors: erco [...] seriss.com
Cc:
AdminCc:

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



Subject: Re: Process::Create() not searching PATH for partial executable name
Date: Tue, 26 Dec 2006 11:14:55 -0800
To: bug-libwin32 [...] rt.cpan.org
From: Greg Ercolano <erco [...] seriss.com>
Download (untitled) / with headers
text/plain 1.2k
Followup. OK, I tracked the problem down to the Process.cpp file in libwin32-0.26. Seems if a value of 0 is passed from the perl program for the 'appname' or 'cmdline' arguments to Process::Create(), it still comes into the C code as the string "0" instead of a 0 (or NULL). I found I could fix (a hack) the problem by modifying the Create() function in libwin32-0.26/Process/Process.cpp, adding checks to see if the arguments are "0", and passing them on as NULL: ---- snip static BOOL Create(cProcess* &cP, char* szAppName, char* szCommLine, DWORD Inherit, DWORD CreateFlags, char* szCurrDir) { BOOL bRetVal; void *env = NULL; #ifdef PERL_IMPLICIT_SYS env = PerlEnv_get_childenv(); #endif cP = NULL; + if (szAppName && strcmp(szAppName, "0") == 0) szAppName = 0; // allow NULL + if (szCommLine && strcmp(szCommLine, "0") == 0) szCommLine = 0; // allow NULL try { --- snip ..which lets me run programs without specifying absolute paths in perl. I'm not sure how the C side of the code is supposed to 'correctly' know the difference between 0 and "0" in the perl program.. I'm not familiar with perl extensions/XS, so possibly the correct fix involves modifying the .xs or .pm files. Or maybe there's an existing way for the perl side to specify a NULL correctly. Comments welcome.
Subject: Re: [rt.cpan.org #24101] AutoReply: Re: Process::Create() not searching PATH for partial executable name
Date: Wed, 27 Dec 2006 03:55:22 -0800
To: bug-libwin32 [...] rt.cpan.org
From: Greg Ercolano <erco [...] seriss.com>
Download (untitled) / with headers
text/plain 2.7k
OK, after reading perlguts and perlxs (woof) I think I get it. The right approach might be to allow 'undef' on the perl side to be used where NULL would be needed on the C side to pass to CreateProcess(). So it seems the simple solution might be to make this simple two line change to Process.xs: Show quoted text
_____________________________________________________________________________ --- Process/Process.xs 2005-09-17 12:36:38.000000000 -0700 +++ Process/Process.xs.erco 2006-12-27 03:19:29.000000000 -0800 @@ -283,6 +283,8 @@ DWORD flags char *curdir CODE: + appname = SvOK(ST(1)) ? appname : 0; + cmdline = SvOK(ST(2)) ? cmdline : 0; RETVAL = Create(cP, appname, cmdline, inherit, flags, curdir); OUTPUT: cP
_____________________________________________________________________________ ..which then makes this work correctly: Process::Create($pobj, undef, "netstat -an", 1, NORMAL_PRIORITY_CLASS, "."); The docs should cover this, so I've included some recommended text:
_____________________________________________________________________________ --- Process/Process.pm 2006-12-27 03:43:02.000000000 -0800 +++ Process/Process.pm.new 2006-12-27 03:42:13.000000000 -0800 @@ -102,14 +102,33 @@ Args: $obj container for process object - $appname full path name of executable module - $cmdline command line args + $appname full path name of executable module (can be 'undef') + $cmdline command line args (can be 'undef') $iflags flag: inherit calling processes handles or not $cflags flags for creation (see exported vars below) $curdir working dir of new process Returns non-zero on success, 0 on failure. +$appname can be 'undef' to allow $cmdline to specify the command without +an absolute path; $ENV{PATH} will be searched to find the executable. eg: + + Win32::Process::Create($ProcessObj, + undef, + "netstat -an", # finds "netstat.exe" from $ENV{PATH} + 0, + NORMAL_PRIORITY_CLASS, + "."); + +See Microsoft's CreateProcess() docs for details. For instance, only .exe's will +be searched; if you are trying to run a .com or .bat, you'll have to specify the +extension, eg: + + Win32::Process::Create($ProcessObj, + undef, + "tree.com /A /F", + [..] + =item Win32::Process::Open($obj,$pid,$iflags) Creates a handle Perl can use to an existing process as identified by $pid.
_____________________________________________________________________________ -Greg Ercolano


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.