You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@apr.apache.org by Antonia Tugores <at...@gridsystems.com> on 2008/01/31 10:55:49 UTC
win32, apr_process_create and cmd.exe
Hi everybody,
I'm having some troubles with apr_process_create in win32 platforms. When I
try to execute cmd.exe the result is a message like "The system can't find the
specified path". The command type I used is APR_SHELLCMD_ENV, so cmd is in
the path. With other applications it worked fine, the only one that fails is
cmd.exe.
In http://markmail.org/message/opveualuzkdkz4ea I found this:
"On windows, some process such as cmd.exe would mysteriously fail to start if
they didn't exist in a console, e.g. when cmd.exe is run in a service
context. Both bugs can be hard to track down for the typical user."
I tried setting apr_procattr_detach_set to true, but it didn't work.
Can anybody give me a clue?
By the way, I am not using pipes nor std_out/err files, and the apr version I
use is 1.2.11.
M. Antonia
Re: win32, apr_process_create and cmd.exe
Posted by Antonia Tugores <at...@gridsystems.com>.
On Thursday 31 January 2008 17:32:26 William A. Rowe, Jr. wrote:
> Antonia Tugores wrote:
> > I'm having some troubles with apr_process_create in win32 platforms. When
> > I try to execute cmd.exe the result is a message like "The system can't
> > find the specified path". The command type I used is APR_SHELLCMD_ENV, so
> > cmd is in the path. With other applications it worked fine, the only one
> > that fails is cmd.exe.
> >
> > By the way, I am not using pipes nor std_out/err files, and the apr
> > version I use is 1.2.11.
>
> There's your problem, I'm guessing. Set up (even to "NUL" file) your std
> in/out/err, and cmd.exe should stop wigging out.
>
> cmd.exe can't run in a vaccum. Also, if it's shellcmd, why would you
> invoke a shell of a shell? That's a whole lot of indirection.
> APR_PROGRAM_ENV sounds like what you wanted.
The problem is not the shell into a shell because when invoking "dir" (without
the cmd.exe) I had the same problem.
I'm invoking it as: cmd.exe /C dir > std.out 2> std.err, but I am not using
apr_files.
I'm setting apr_procattr_io_set(pattr, APR_NO_PIPE, APR_NO_PIPE, APR_NO_PIPE)
and setting the in/out/err to NULL is not working too.
And I cannot change it to APR_PROGRAM_ENV because the application I am working
with must run all kind of cmd programs, included cmd ;)
Code example with no error control to shorten the mail:
apr_procattr_t *pattr;
apr_procattr_create(&pattr, mp)) != APR_SUCCESS);
apr_procattr_io_set(pattr, APR_NO_PIPE, APR_NO_PIPE, APR_NO_PIPE);
apr_procattr_cmdtype_set(pattr, APR_SHELLCMD_ENV);
char * progname = "cmd.exe /C dir > std.out 2> std.err"; <------ command to
execute
int argc = 0;
const char* argv[APP_MAX_ARGC];
apr_proc_t proc;
argv[argc++] = progname;
argv[argc++] = NULL;
apr_proc_create(&proc, progname, (const char* const*)argv, NULL,
(apr_procattr_t*)pattr, mp);
M. Antònia
Re: win32, apr_process_create and cmd.exe
Posted by "William A. Rowe, Jr." <wr...@rowe-clan.net>.
Antonia Tugores wrote:
>
> I'm having some troubles with apr_process_create in win32 platforms. When I
> try to execute cmd.exe the result is a message like "The system can't find the
> specified path". The command type I used is APR_SHELLCMD_ENV, so cmd is in
> the path. With other applications it worked fine, the only one that fails is
> cmd.exe.
>
> By the way, I am not using pipes nor std_out/err files, and the apr version I
> use is 1.2.11.
There's your problem, I'm guessing. Set up (even to "NUL" file) your std
in/out/err, and cmd.exe should stop wigging out.
cmd.exe can't run in a vaccum. Also, if it's shellcmd, why would you invoke
a shell of a shell? That's a whole lot of indirection. APR_PROGRAM_ENV
sounds like what you wanted.