home *** CD-ROM | disk | FTP | other *** search
/ C!T ROM 2 / ctrom_ii_b.zip / ctrom_ii_b / PROGRAM / C / FS191 / XSPAWN33 / DEMO.C next >
Text File  |  1991-05-04  |  2KB  |  60 lines

  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <string.h>
  4. #ifdef MSC
  5. #include <direct.h>
  6. #endif
  7. #ifdef MSC4
  8. #include <direct.h>
  9. #endif
  10. #ifdef TC
  11. #include <dir.h>
  12. #endif
  13. #ifdef TCPP
  14. #include <dir.h>
  15. #endif
  16. #ifdef LATTICE
  17. #include <errno.h>
  18. #endif
  19. #include "xspawn.h"
  20.  
  21. void main()
  22. {
  23.     char *env;
  24.     char cwd[ 67 ];                    /* current working directory */
  25.  
  26.     /*
  27.      *  If the user has a "TMP" environment variable, it very possibly is set
  28.      *  to the drive name of a ramdrive.  Construct an example _swappath.
  29.      *  Since _useems is 0 by default, _swappath may not be used.
  30.      */
  31.     if (( env = getenv( "TMP" )) != NULL && getcwd( cwd, 66 ) != NULL &&
  32.         ( _swappath = ( char * )malloc( strlen( env ) + strlen( cwd ) + 2 )) !=
  33.         NULL )
  34.     {
  35.         strcpy( _swappath, env );      /* try this path first */
  36.         strcat( _swappath, ";" );
  37.         strcat( _swappath, cwd );      /* try this path last */
  38.     }
  39.  
  40.     _swap = 1;                         /* turn swap off */
  41.  
  42.     printf( "\nxspawnlp mm.com without swap\n" );
  43.     if ( xspawnlp( P_WAIT, "mm.com", "mm.com", NULL ) == -1 )
  44.     {
  45.         printf( "xspawnlp failed, errno = %d", errno );
  46.         exit( 1 );
  47.     }
  48.  
  49.     _swap = 0;                         /* turn swap on */
  50.  
  51.     printf( "\nxspawnlp mm.com with swap\n" );
  52.     if ( xspawnlp( P_WAIT, "mm.com", "mm.com", NULL ) == -1 )
  53.     {
  54.         printf( "xspawnlp failed, errno = %d", errno );
  55.         exit( 1 );
  56.     }
  57.  
  58.     exit( 0 );
  59. }
  60.