shithub: drawterm

Download patch

ref: b9cc48602d982354df31465eeb16666e72a96799
parent: 7d7ddbc142a30bdaf746b4d106b6a9b3e2c74982
author: cinap_lenrek <cinap_lenrek@felloff.net>
date: Sun Sep 18 11:58:09 EDT 2016

win32: fix semaphore leak in osproc()

--- a/kern/win32.c
+++ b/kern/win32.c
@@ -83,21 +83,6 @@
 	Sleep(0);
 }
 
-static DWORD WINAPI tramp(LPVOID vp);
-
-void
-osproc(Proc *p)
-{
-	DWORD tid;
-
-	if(CreateThread(0, 0, tramp, p, 0, &tid) == 0) {
-		oserror();
-		panic("osproc: %r");
-	}
-
-	Sleep(0);
-}
-
 static DWORD WINAPI
 tramp(LPVOID vp)
 {
@@ -106,15 +91,20 @@
 
 	_setproc(p);
 	op->tid = GetCurrentThreadId();
-	op->sema = CreateSemaphore(0, 0, 1000, 0);
-	if(op->sema == 0) {
-		oserror();
-		panic("could not create semaphore: %r");
-	}
-
  	(*p->fn)(p->arg);
 	ExitThread(0);
 	return 0;
+}
+
+void
+osproc(Proc *p)
+{
+	DWORD tid;
+
+	if(CreateThread(0, 0, tramp, p, 0, &tid) == 0) {
+		oserror();
+		panic("osproc: %r");
+	}
 }
 
 void