Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Can't spawn "cmd.exe":

by Sandy (Curate)
on Mar 18, 2009 at 14:50 UTC ( #751460=note: print w/ replies, xml ) Need Help??


in reply to Can't spawn "cmd.exe":

I'm not sure if this is relevant, but check the following node:

Re: system command erroneously states 'can't spawn <executable>' from jimbojones

The code (from 5.8.9) win32.c that might be causing the problem

int Perl_do_aspawn(pTHX_ SV *really, SV **mark, SV **sp) { char **argv; char *str; int status; int flag = P_WAIT; int index = 0; if (sp <= mark) return -1; get_shell(); Newx(argv, (sp - mark) + w32_perlshell_items + 2, char*); if (SvNIOKp(*(mark+1)) && !SvPOKp(*(mark+1))) { ++mark; flag = SvIVx(*mark); } while (++mark <= sp) { if (*mark && (str = SvPV_nolen(*mark))) argv[index++] = str; else argv[index++] = ""; } argv[index++] = 0; status = win32_spawnvp(flag, (const char*)(really ? SvPV_nolen(really) : argv[0]), (const char* const*)argv); if (status < 0 && (errno == ENOEXEC || errno == ENOENT)) { /* possible shell-builtin, invoke with shell */ int sh_items; sh_items = w32_perlshell_items; while (--index >= 0) argv[index+sh_items] = argv[index]; while (--sh_items >= 0) argv[sh_items] = w32_perlshell_vec[sh_items]; status = win32_spawnvp(flag, (const char*)(really ? SvPV_nolen(really) : argv[0] +), (const char* const*)argv); } if (flag == P_NOWAIT) { PL_statusvalue = -1; /* >16bits hint for pp_system() */ } else { if (status < 0) { if (ckWARN(WARN_EXEC)) Perl_warner(aTHX_ packWARN(WARN_EXEC), "Can't spawn \"%s\": %s +", argv[0], strerror(errno)); status = 255 * 256; } else status *= 256; PL_statusvalue = status; } Safefree(argv); return (status); }
Notice that if the executable returns a negative error code, the assumption is that the spawn didn't work.


Comment on Re: Can't spawn "cmd.exe":
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://751460]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (9)
As of 2014-12-23 03:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (135 votes), past polls