Terminating a Process

A process may terminate another process running in the system, provided it has access to the process ID of the process it wishes to terminate. This process ID is returned by the DosExecPgm() function when the process is created and since, in the majority of cases, a process is terminated by the process that created it, this presents no particular problem since the process ID can be stored as a global variable or as instance data in window words, until it is needed to terminate the process.

A process is terminated using the DosKillProcess() function. This function may be used to terminate a single process, or to terminate a process and all its descendants (that is, its children, along with their children, and so on). An example of the DosKillProcess() function is given in Figure "Terminating a Process".

The value of "1" specified for the first parameter in the DosKillProcess() call causes the function to terminate only the specified process and not its descendants (if any).


[Back: Forcing Termination of a Thread]
[Next: Communicating With a Secondary Thread]