Date: Tue, 21 Nov 1995 10:25:23 -0500 From: kagel AT quasar DOT bloomberg DOT com To: eliz AT is DOT elta DOT co DOT il Cc: A DOT APPLEYARD AT fs2 DOT mt DOT umist DOT ac DOT uk, DJGPP AT sun DOT soe DOT clarkson DOT edu Subject: Re: Trouble spawning Reply-To: kagel AT ts1 DOT bloomberg DOT com Date: Tue, 21 Nov 1995 15:30:48 +0200 (IST) From: Eli Zaretskii On Tue, 21 Nov 1995, A.Appleyard wrote: > 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, 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. A case of misunderstanding the docs (which probably aren't clear enough). The spawnXXX() family functions should be passed argv[0] twice: once as the full pathname and once as the first member in the arguments' array, like this: spawnl(P_WAIT, "c:/bin/pkzip.exe", "c:/bin/pkzip.exe", "file.zip", 0); (One of the reasons for this double argument is compatibility to other implementations of C under DOS, but there might be others, I don't remember.) Yes. Compatibility with other DOS implementations which themselves paralleled the execl function in UNIX. This was done in UNIX to allow one to start off a program from a full path but put another, perhaps shorter, perhaps different, name into the child program's argv[0]. This can allow the program to easily modify its behavior based on its argv[0] name. If this is a name not linked to its executable it can know it has been exec'd by a parent program, rather than from the command line, and behave appropriately. (Example: ex, vi, and view are links to the same file which comes up in full screen mode if exec'd as vi, read only screen mode if exec'd as view, and in line oriented mode if exec'd as ex. Ex may, for example, have some hidden mode that has it act like, say, an enhanced sed when invoked as 'esed' but since there is no file system link to the executable named esed so only a knowledgable parent program using execl() could get the mode.) -- Art S. Kagel, kagel AT ts1 DOT bloomberg DOT com The sky is the daily bread of the eyes. -- Ralph Waldo Emerson