www.delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1995/11/22/01:05:17

Date: Tue, 21 Nov 1995 23:06:04 -0500
From: dj (DJ Delorie)
To: A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk
Cc: DJGPP AT sun DOT soe DOT clarkson DOT edu
Subject: Re: Trouble spawning

>   I have a Gnu C++ program that calls PKUNZIP.EXE thus:-
>     k=spawnl(P_WAIT,UNZIP,ZIPWF,0);
>   where P_WAIT is defined in #include<process.h>, UNZIP is a char* -> the full
> pathname of my copy of PKUNZIP.EXE, ZIPWF is a char* -> the full pathname of
> the zipfile that I want to unzip. But always when called thus, PKUNZIP behaves
> as it behaves when I call it directly from DOS without any arguments.

For spawnl*(), the argument list is like this:

	spawnv(P_WAIT, program, argv[0], argv[1], ..., argv[N], 0);

Note that the program name is listed TWICE, once as the file to run,
and once as the argv[0] parameter to pass.

For spawnv*(), the third argument, ZIPFW, should be an array of char*
like this:

	char *ZIPWF[] = {
		"pkunzip",
		"-v",
		"somefile.zip",
		0 };

As you can see, it represents the command line arguments (argv[*]),
and again, the first element is the program name, just like the second
argument to the function.

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019