tomliew@itsgw.rpi.edu (TomLiew) (02/07/91)
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 ...] > >-- >Bitnet: pmrcjdb@uchimvs1 >Internet: cjdb@midway.uchicago.edu 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); ...... ******************************************************* -- Thomas Liew Internet : tomliew@itsgw.rpi.edu Physics Dept. RPI Bitnet : fhv1@rpitsmts Troy, NY12180 *******************************************************************
tomliew@itsgw.rpi.edu (TomLiew) (02/07/91)
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 *******************************************************************