Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Zortech C++ Language Reference - spawn http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
   spawn

   Usage
   #include <process.h>
   int spawnl(int mode,char *pathname,
   char *arg0, *arg1,...,*argn, NULL);
   int spawnlp(int mode,char *filename,
   char *arg0, *arg1,...,*argn, NULL);
   int spawnv(int mode,char *pathname,char *argv[]);
   int spawnvp(int mode,char *filename,char *argv[]);

   Description
   The  spawn  system calls load and execute a new  child  process.  More
   simply,  a  new program is run then the old one  continues.  It  works
   similarly to calling a subroutine.

   Creating  a  new subprocess requires memory to be  available  for  the
   child  process  to  execute in addition to that used  by  the  current
   program.  See  the introduction to this section of the  manual  for  a
   description of the memory usage during a spawn call. The mode flag  is
   ignored.  It  may be used for future versions. Use a value  of  0  for
   mode.

   The  filename argument specifies the program to execute.  For  spawnlp
   and spawnvp only, if the filename doesn't have a path and it is not in
   the  current directory then the environment variable PATH is  used  to
   determine which directories are searched for the file. The argv[0]  is
   just a place holder and is not passed to the subprocess. This is  used
   for compatibility only, but should always be included for portability.
   It should be the name of the program that is to run.

   The  command  line passed to the spawn-ed program is made  up  of  the
   character  strings  in the spawn call, the first  being  arg1,  second
   arg2,  etc. The combined length of these strings must not  exceed  128
   characters.

   The  argv  argument  used in the spawnv and spawnvp is  an  array  of
   character pointers. The last pointer in argv must be NULL to  indicate
   the end of the list.

   Example
   #include <stdio.h>
   #include <process.h>

   main()
   {
   char *args[4];
        args[0] = "ztc1.exe";
        args[1] = "stuff";
        args[2] = "morestuff";
        args[3] = NULL;

        if(spawnv(0,"C:ZTC1.EXE",args) == -1)
                  fprintf(stderr,"exec failed!\n");
   }

   Return Value
   The return value indicates the exit status of the spawn-ed program.  A
   value of 0 indicates that the spawn-ed program executed  successfully.
   A positive value indicates that the spawn-ed program executed, but was
   aborted  or ended in error, the value returned is the exit  status  of
   the  child  process.  A negative value  indicates  that  the  spawn-ed
   program did not execute, and errno is set.


See Also: abort exit exec system

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson