DosKillProcess: Difference between revisions
Appearance
Created page with "==DosKillProcess== ===Syntax=== rc = DosKillProcess( ''ulAction'', ''pid'' ); ===Parameters=== ; ULONG ''ulAction'' (input) : Sets the processes to be terminated. Values are..." |
|||
(6 intermediate revisions by 2 users not shown) | |||
Line 1: | Line 1: | ||
== | ==Syntax== | ||
rc = DosKillProcess( ''ulAction'', ''pid'' ); | |||
==Parameters== | |||
;ULONG ''ulAction'' (input):Sets the processes to be terminated. Values are: | |||
::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 | #define INCL_DOSPROCESS | ||
#include <os2.h> | #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. | |||
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. | |||
==Sample Code== | |||
<code> | |||
#define INCL_DOSPROCESS | #define INCL_DOSPROCESS | ||
#include <os2.h> | #include <os2.h> | ||
Line 58: | Line 38: | ||
/* There is a problem killing the process */ | /* There is a problem killing the process */ | ||
} | } | ||
</code> | |||
==See Also== | |||
*[[DosExecPgm]] | |||
*[[DosWaitChild]] | |||
*[[DosExit]] | |||
*[[DosStartSession]] | |||
[[ | [[Category:Dos]] |
Latest revision as of 00:19, 4 May 2020
Syntax
rc = DosKillProcess( ulAction, pid );
Parameters
- ULONG ulAction (input)
- Sets the processes to be terminated. Values are:
- 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.
Sample Code
#define INCL_DOSPROCESS
#include <os2.h>
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 */
}