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++ 3.0r4 - <b>spawnl</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
spawnl
spawnlp
spawnv
spawnvp

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. The current
   process may or may not continue to execute asynchronously. Creating a new
   subprocess requires memory to be available for the child process to
   execute in addition to that used by the current program.

   The mode argument determines whether or not the child process is to run
   asynchronously. It is currently only used under OS/2, and allows
   multitasking between the parent and child processes. Values for mode are:

   EXEC_SYNC        Run synchronously. The parent process waits for the child
                    process to terminate before continuing.

   EXEC_ASYNC       Run asynchronously. The parent and child processes execute
                    in parallel.

   EXEC_ASYNCRESULT Run asynchronously. The parent and child processes
                    execute in parallel. The termination code of the child
                    process can be recovered using the OS/2 API function
                    DosCwait().

   EXEC_BACKGROUND  Run asynchronously. The parent and child processes
                    execute in parallel, but the child process is detached
                    from the screen group of its parent process. The
                    detached process executes in the background and may not
                    use screen output (except VioPopUp()) or the keyboard or
                    mouse subsystems.

   EXEC_TRACE       Execute under conditions for tracing. Used by debuggers to
                    debug the child process.


   The filename argument specifies the program to execute. For spawnlp and
   spawnvp only, if the filename does not 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 string pointed to by
   argv[0] should be the name of the program that is to run. The command
   line passed to the spawned 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.

   The spawn functions can be used under Microsoft Windows.  They use
   LoadModule to run the spawned process. If this fails an attempt is made
   to spawn a normal MS-DOS process. If a Windows application is spawned,
   the instance handle can be obtained using _exec_instancehandleget(). It
   is possible to specify how the spawned program is to be shown using the
   functions _exec_showset(), _exec_showget() and _exec_showreset(). Refer
   to the entries for those functions for more information.

Example 

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

   int main()
   {
       char *args[4];

       args[0] = "ztc1";
       args[1] = "stuff";
       args[2] = "morestuff";
       args[3] = NULL;
       if(spawnv(0,"ZTC1.EXE",args) == -1) {
           fprintf(stderr,"exec failed!\n");
           return EXIT_FAILURE;
       }
       return EXIT_SUCCESS;
   }

Return Value

   The return value indicates the exit status of the spawned program. A
   value of 0 indicates that the spawned program executed successfully. A
   positive value indicates that the spawned 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 spawned program did
   not execute, and errno is set.

   Under Microsoft Windows spawn returns the negated error code returned
   from LoadModule for compatibility with the C runtime library. The
   following error codes may be encountered:

   -2               File not found

   -3               Path not found

   -11              Invalid .exe file (for Windows)

   -13              Dos 4.0 application

   -14              Unknown .exe type (may be DOS extended)


See Also

   abort, exit, exec, system




See Also: abort exit exec system

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