More on spawn

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

More on spawn

James Rome
I got the spawnlp function to work properly in both Cygwin and MinGW. I
am updating this so others might be helped.

    char *TP_LOCATION = "C:/Users/jar/Tekdraw2/tekPlot/dist/tekPlot.jar";
    char *JAVA_LOCATION ="\" C:/Program Files (x86)/Java/jre6/bin/java\"";

        sprintf(portstr, "%d", port);
        // start Java
        if (spawnlp(_P_NOWAIT, "java",
                JAVA_LOCATION,
                "-jar", TP_LOCATION,
                portstr, NULL) < 0) {
            perror("spawnlp failed");
            exit(EXIT_FAILURE);
        }

The key is the double quotes. The Java location requires them, but the
jar location requires that they NOT be there. So, if the jar file
location had a space in the path, how would one specify this?

------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: More on spawn

Earnie Boyd
James Rome wrote:

> I got the spawnlp function to work properly in both Cygwin and MinGW. I
> am updating this so others might be helped.
>
>      char *TP_LOCATION = "C:/Users/jar/Tekdraw2/tekPlot/dist/tekPlot.jar";
>      char *JAVA_LOCATION ="\" C:/Program Files (x86)/Java/jre6/bin/java\"";
>
>          sprintf(portstr, "%d", port);
>          // start Java
>          if (spawnlp(_P_NOWAIT, "java",
>                  JAVA_LOCATION,
>                  "-jar", TP_LOCATION,
>                  portstr, NULL)<  0) {
>              perror("spawnlp failed");
>              exit(EXIT_FAILURE);
>          }
>
> The key is the double quotes. The Java location requires them, but the
> jar location requires that they NOT be there. So, if the jar file
> location had a space in the path, how would one specify this?
>

Use the 8.3 form of the path name.  Spaces in path names are evil.

--
Earnie
-- http://www.for-my-kids.com

------------------------------------------------------------------------------

_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: More on spawn

Keith Marshall
On Wednesday 02 June 2010 19:04:42 Earnie wrote:
> > The key is the double quotes. The Java location requires them,
> > but the jar location requires that they NOT be there. So, if the
> > jar file location had a space in the path, how would one specify
> > this?
>
> Use the 8.3 form of the path name.  Spaces in path names are evil.

That's certainly an option, but if the java application really does
require that they not be present, then it is broken.  Any application
on Windoze, which obtains arguments from the command line, will just
receive those arguments as a single string, which it MUST parse for
itself.  That parsing step is responsible for splitting the string
into individual arguments, and it MUST properly handle and reduce
double quotes used to delimit those individual arguments.

In addition to this observation, I will once again point out that
Microsoft's implementation of the spawn and exec family of functions,
as implemented in MSVCRT, is also broken wrt the correct passing of
original arguments; where those arguments contain embedded white
space, they are NOT properly protected from word splitting, as they
should be, when reparsed in the spawned process.  If you are
comfortable with using GPL code, we do provide the execwrap package,
derived from code which I originally wrote for the GNU troff (groff)
project, (a GNU and hence GPL project), to (almost) transparently and
automatically correct this very defect.

--
Regards,
Keith.

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
MinGW-users mailing list
[hidden email]

This list observes the Etiquette found at
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Reply | Threaded
Open this post in threaded view
|

Re: More on spawn

mohd
This post has NOT been accepted by the mailing list yet.
In reply to this post by James Rome
Thanks!