Article View: comp.os.msdos.programmer
Article #4570Re: spawn problem
From: TomLiew
Date: Thu, 07 Feb 1991 05:16
Date: Thu, 07 Feb 1991 05:16
48 lines
2465 bytes
2465 bytes
In article <7Z^&X`#@rpi.edu> tomliew@itsgw.rpi.edu (TomLiew) writes:
>In article <CHAS.91Feb3040833@stax.uchicago.edu> chas@stax.uchicago.edu (Charles Blair) writes:
>>
>>I'm spawning a child program written in assembly language from a
>>parent written in C as follows:
>>
>> spawnlp(P_WAIT,"WHATEVER.EXE","",NULL);
>> exit(0);
[ stuff deleted ...]
>You forgot arg0. If you look inside the reference manual you fill find spawnlp defined as follows:
>
>int spawnlp(int mode, char *cmdname, char *arg0, char *arg1,...,argn,NULL);
>
>cmdname : Path name of the file to be executed.
>arg0,...argn : List of pointers to arguments, terminated by NULL.
>
>At least one argument, arg0, must be passed to the child process(which
>sees it as argv[0]). This argument is usually a copy of the cmdname
>i.e a pointer to the path
>
>The statement should then be :
> spawnlp(P_WAIT,"whatever.exe","whatever",NULL);
> ......
Charles, you are right. The exit() brings it back to the shell. After
reading your followup post, I tried spawnlp( ) without arg0 and it works
okay. Sorry if I mislead you. I guess you could still use exit() if
you test the return code of spawnlp(). That is what I always do to
make sure that the child process has be executed successfully. According
to my MSC 5.1 reference guide if spawnlp() returns a value of -1, an error
has occured.
something like ...
... parent ...
if ( spawnlp(..) < 0 ) {
process the error
exit(); /* if you choose to do so */
}
.... parent
Happy Spawning.......and be productive(NO FLAMES).
*******************************************************************
--
Thomas Liew Internet : tomliew@itsgw.rpi.edu
Physics Dept. RPI Bitnet : fhv1@rpitsmts
Troy, NY12180
*******************************************************************
Technical Details
Message-ID:
<S4^&}7#@rpi.edu>Path:
arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!tomliewReferences:
<CHAS.91Feb3040833@stax.uchicago.edu> <7Z^&X`#@rpi.edu>Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!wuarchive!zaphod.mps.ohio-state.edu!rpi!tomliew From: tomliew@itsgw.rpi.edu (TomLiew) Newsgroups: comp.os.msdos.programmer Subject: Re: spawn problem Message-ID: <S4^&}7#@rpi.edu> Date: 7 Feb 91 05:16:28 GMT References: <CHAS.91Feb3040833@stax.uchicago.edu> <7Z^&X`#@rpi.edu> Distribution: comp.sys.ibm.pc.programmer,comp.os.msdos.programmer Organization: Rensselaer Polytechnic Institute, Troy NY Lines: 48 Nntp-Posting-Host: jec423.its.rpi.edu