You can start a child process in the background by specifying the EXEC_BACKGROUND constant in DosExecPgm. A background process runs independently of the parent process and is called a detached process. A detached process should not require any input from the keyboard or output to the video screen, but it can use interprocess communication, such as pipes, queues, and shared memory.
The following code fragment starts the program BATCH.EXE in the background.
#define INCL_DOSPROCESS /* Process and thread values */ #include <os2.h> #include <stdio.h> #define START_PROGRAM "BATCH.EXE" CHAR szLoadError[100]; PSZ pszArgs; PSZ pszEnvs; RESULTCODES rcReturnCodes; APIRET ulrc; ulrc = DosExecPgm(szLoadError, /* Object name buffer */ sizeof(szLoadError), /* Length of object name buffer */ EXEC_BACKGROUND, /* Asynchronous/Trace flags */ pszArgs, /* Argument string */ pszEnvs, /* Environment string */ &rcReturnCodes, /* Termination codes */ START_PROGRAM); /* Program file name */ if (ulrc != 0) { printf("DosExecPgm error: return code = %ld", ulrc); return; }