Thread (48 messages) flat view 48 messages, 3 authors, 2016-06-15

Re: [msysGit] [PATCH/RFC 06/11] run-command: add kill_async() and is_async_alive()

From: Johannes Sixt <hidden>
Date: 2016-06-15 22:47:46

On Donnerstag, 26. November 2009, Erik Faye-Lund wrote:
+int kill_async(struct async *async)
+{
+#ifndef WIN32
+	return kill(async->pid, SIGTERM);
+#else
+	DWORD ret = 0;
+	if (!TerminateThread(async->tid, 0))
+		ret = error("killing thread failed: %lu", GetLastError());
Ugh! Did you read the documentation of TerminateThread()?

We need to kill processes/threads when we detect that there are too many 
connections. But TerminateThread() is such a dangerous function that we 
cannot pretend that everything is good, and we continue to accept 
connections.

Unless we find a different solution, I would prefer to punt and die instead.
+	else if (!GetExitCodeThread(async->tid, &ret))
+		ret = error("cannot get thread exit code: %lu", GetLastError());
What should the exit code be good for? The return value of this function can 
only be -1 (failure, could not kill) or 0 (success, process killed).

-- Hannes
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help