dos12.hlp (Table of Contents; Topic list)
Important Notice
The pages on this site contain documentation for very old MS-DOS software, purely for historical purposes. If you're looking for up-to-date documentation, particularly for programming, you should not rely on the information found here, as it will be woefully out of date.
DosKillProcess (1.2)
Function Group  Overview                          Up Next Previous
────────────────────────────────────────────────────────────────────────────
 
#define INCL_DOSPROCESS
 
USHORT DosKillProcess(fScope, pidProcess)
USHORT fScope;     /* scope                                     */
PID pidProcess;    /* process identifier of process to be ended */
 
The DosKillProcess function terminates the specified process, with the
option of also terminating all child processes that belong to it. Any
subsequent request for the process's termination code returns the
TC_KILLPROCESS code, unless the process intercepted the termination
request.
 
Parameter   Description
────────────────────────────────────────────────────────────────────────────
 
fScope      Specifies whether to terminate the child processes that belong
            to the specified process that is to be terminated. This
            parameter may be one of the following values:
 
            Value            Meaning
            ────────────────────────────────────────────────────────────────
            DKP_PROCESSTREE  Terminates the specified process and all of its
                             child processes.
 
            DKP_PROCESS      Terminates the specified process only.
 
pidProcess  Specifies the process identifier of the process to terminate.
 
Return Value
 
The return value is zero if the function is successful. Otherwise, it is an
error value, which may be the following:
 
     ERROR_INVALID_PROCID
 
Comments
 
A process can intercept the termination request generated by the
DosKillProcess function by using the DosSetSigHandler function to create a
signal handler. When the process creates a signal handler, the process
typically completes any termination tasks, such as copying data from local
buffers to files, then calls the DosExit function to terminate. If a process
has no signal handler, the DosKillProcess function terminates the process
after flushing all system file buffers and closing all handles opened by the
process.
 
Before terminating, the process being terminated must flush file buffers
that are not managed by MS OS/2──for example, the buffers managed by the C
run-time library. MS OS/2 does not flush these buffers as part of its
termination sequence.
 
Example
 
This example creates the child process abc.exe, then calls the
DosKillProcess function to terminate it:
 
UCHAR szFailName[CCHMAXPATH];
RESULTCODES resc;
DosExecPgm(szFailName, sizeof(szFailName),
    EXEC_ASYNCH, "abc\0", 0, &resc, "abc.exe");
    .
    .
    .
DosKillProcess(DKP_PROCESS, resc.codeTerminate);
 
See Also
 
DosCwait, DosExit, DosSetSigHandler