ソースを参照

[FreeProcess] Add Win32 support for TProcess.Kill()

Ronny Otto 6 年 前
コミット
d214e56409
1 ファイル変更23 行追加0 行削除
  1. 23 0
      freeprocess.mod/freeprocess.c

+ 23 - 0
freeprocess.mod/freeprocess.c

@@ -169,6 +169,17 @@ extern int _bbusew;
 #include <tlhelp32.h>
 
 int TerminateProcessGroup(HANDLE prochandle,int procid)
+{
+	//for now we just do a kill instead of politely asking all
+	//sub-windows (gui only) to gracefully end.
+	return KillProcessGroup(prochandle, procid);
+}
+
+
+// In the Windows world "TerminateProcess" kills a process without
+// gracefully asking to stop I/O and other operations first.
+// So there is a name clash between Linux' SIGKILL and Windows' TERMINATE
+int KillProcessGroup(HANDLE prochandle,int procid)
 {
 	HANDLE snapshot,child;
 	PROCESSENTRY32 procinfo;
@@ -268,6 +279,18 @@ int fdTerminateProcess( int pid ){
 	return res;
 }
 
+//returns 0 for success
+int fdKillProcess( int pid ){
+	PROCESS_INFORMATION *pi=(PROCESS_INFORMATION *)pid;
+
+	int res=KillProcessGroup( pi->hProcess,pi->dwProcessId );
+
+	CloseHandle( pi->hProcess );
+	free( pi );
+
+	return res;
+}
+
 int fdProcess( BBString *cmd,int *procin,int *procout,int *procerr,int flags)
 {
 	int res;