home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1993 #1 / NN_1993_1.iso / spool / comp / os / msdos / programm / 11897 < prev    next >
Encoding:
Text File  |  1993-01-07  |  1.9 KB  |  64 lines

  1. Newsgroups: comp.os.msdos.programmer
  2. Path: sparky!uunet!wupost!csus.edu!borland.com!news!cfortier
  3. From: cfortier@genghis.news (Chris Fortier)
  4. Subject: Re: question on spawning DOS from C prog
  5. In-Reply-To: jmt7@ns1.cc.lehigh.edu's message of 7 Jan 93 14:05:24 GMT
  6. Message-ID: <CFORTIER.93Jan7165941@genghis.news>
  7. Sender: news@borland.com (News Admin)
  8. Organization: Borland International, Inc.
  9. References: <1993Jan7.140524.15787@ns1.cc.lehigh.edu>
  10. Date: Fri, 8 Jan 1993 00:59:41 GMT
  11. Lines: 51
  12.  
  13.  
  14.  
  15. In article <1993Jan7.140524.15787@ns1.cc.lehigh.edu> jmt7@ns1.cc.lehigh.edu (JOHN M. TROIANO) writes:
  16.  
  17. [ STUFF DELETED ]
  18.  
  19.    Hi, I am the original poster of this problem: this is especially to
  20.    Tim and Wolfgang. I tried the code below (which is I think what both
  21.    of you guys are suggesting) but it does'nt work (the new prompt
  22.    string is ignored). Any ideas?     - John.
  23.  
  24.    #include <stdio.h>
  25.    #include <process.h>
  26.    #include <dos.h>
  27.    #include <stdlib.h>
  28.  
  29.    int main( int argc, char *argv[], char **envp )
  30.    {
  31.  
  32.    printf( "\ninside main, spawning DOS\n" );
  33.    sleep( 2 );
  34.  
  35.    putenv( "prompt=$_type EXIT to return to program $_$_$p$g" );
  36.  
  37.    spawnlpe( P_WAIT, "command.com", NULL, envp );
  38.  
  39.    printf( "\nback from spawn!\n" );
  40.  
  41.    sleep( 2 );
  42.  
  43.    }
  44.  
  45.  
  46.  
  47. Sigh.  Please RTFM.  The third parameter to spawn???() is argv[], a list of
  48. parameters to the spawned executable.  This means that argv[0] must be the
  49. name of the executable.  I know this seems redundant, but it does have a
  50. purpose (changing path information, passing info to the child program, etc.).
  51.  
  52. Change the spawn???() command to the following, and the program should work:
  53.  
  54.     spawnlpe(P_WAIT, "command.com", "command.com", NULL, envp);
  55.                                 ^              ^              
  56.                                 |              |        
  57.                                path         argv[0]     
  58.  
  59.  
  60. Chris Fortier
  61. Borland C++ Run Time Library QA
  62.  
  63. cfortier@borland.com
  64.