int ret;
struct command_read_ctx actx, *ctx = &actx;
DWORD threadid;
+ HANDLE hThread;
fputs(prompt, stdout);
fflush(stdout);
ctx->event = CreateEvent(NULL, FALSE, FALSE, NULL);
ctx->line = NULL;
- if (!CreateThread(NULL, 0, command_read_thread,
- ctx, 0, &threadid)) {
+ hThread = CreateThread(NULL, 0, command_read_thread, ctx, 0, &threadid);
+ if (!hThread) {
+ CloseHandle(ctx->event);
fprintf(stderr, "Unable to create command input thread\n");
cleanup_exit(1);
}
assert(ret >= 0);
} while (ret == 0);
+ CloseHandle(hThread);
+ CloseHandle(ctx->event);
+
return ctx->line;
}