Path: 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: Date: 7 Feb 91 05:16:28 GMT References: <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 In article <7Z^&X`#@rpi.edu> tomliew@itsgw.rpi.edu (TomLiew) writes: >In article 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 *******************************************************************