[ Home |
Alpha index |
Topic index |
Tutorials |
Download |
Feedback ]
The OS/2 API Project
DosKillProcess
[ Syntax |
Params |
Returns |
Include |
Usage |
Structs |
Gotchas |
Code |
Also ]
Syntax
rc = DosKillProcess( ulAction,
pid );
Parameters
-
ULONG ulAction (input)
-
Sets the processes to be terminated. Values are:
Value Name Description
0 DKP_PROCESSTREE Kill the process and all its descendant processes.
Must be either the current process or it must
have been created by the current process using
DosExecPgm with ulFlagS set to EXEC_ASYNCRESULT
(2).
1 DKP_PROCESS Any process and only that process.
-
PID pid (input)
-
Process ID for the process to be killed.
Returns
APIRET rc
0 NO_ERROR
13 ERROR_INVALID_DATA
217 ERROR_ZOMBIE_PROCESS
303 ERROR_INVALID_PROCID
305 ERROR_NOT_DESCENDANT
Include Info
#define INCL_DOSPROCESS
#include <os2.h>
Usage Explanation
DosKillProcess is used to kill a process by its process ID. What happens is
that a KILLPROCESS exception is sent to the given process or group of processes.
This by default will write all file buffers, and handles opened by the process
will be closed. It is possible to intercept the exception with the use of
DosSetExceptionHandler, and then the process will do its own nice exit and call
DosExit. If another process has issued a DosWaitChild for a process terminated
it will get termination code "Unintercepted DosKillProcess" (TC_KILLPROCESS =
3). ERROR_ZOMBIE_PROCESS indicates that the specified process has ended, but
its parent has not yet issued DosWaitChild to get its return code.
Relevant Structures
Gotchas
Sample Code
#define INCL_DOSPROCESS
#include
RESULTCODES ReturnCodes
/* Start a process with DosExecPgm */
/* DosExecPgm(..,.., EXEC_ASYNC,..,.., &ReturnCodes,..); */
/* Kill the process started */
if(DosKillProcess(DKP_PROCESS,ReturnCodes.codeTerminate))
{
/* There is a problem killing the process */
}
See Also
DosExecPgm,
DosWaitChild,
DosExit,
DosStartSession
Author
Oscar Gustafsson -
oscar@lysator.liu.se
Additions
Last modified September 21/1996
Please send all errors, comments, and suggestions to:
timur@vnet.ibm.com
The OS/2 API Project |
DosKillProcess |