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> |
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.