nodejs / uvwasi

WASI syscall API built atop libuv
MIT License
225 stars 49 forks source link

Fix THREAD_CPUTIME clock_time_get on Windows #181

Closed ospencer closed 1 year ago

ospencer commented 1 year ago

@phated and I found that clock_time_get on Windows would return Bad file descriptor when asking for the thread time on Windows, i.e. uvwasi_clock_time_get for UVWASI_CLOCK_THREAD_CPUTIME_ID.

I saw it was just because GetProcessTimes was being called for both processes and threads, but threads specifically need GetThreadTimes.

I added some basic smoke tests (just ensuring the calls don't fail and that the returned times are non-zero), and tested this on a Windows machine and it appears to work.

Let me know if anything else is needed to get this landed 🙂