Skip to content
This repository has been archived by the owner on Nov 20, 2022. It is now read-only.

(on Windows) the spawn example hangs #71

Open
thehoglet opened this issue Oct 20, 2016 · 2 comments
Open

(on Windows) the spawn example hangs #71

thehoglet opened this issue Oct 20, 2016 · 2 comments

Comments

@thehoglet
Copy link

Referring to this code...

Please also refer to this, which I think might be relevant.

After the call to uv_close() in the on_exit callback, the next time the following executes in core.c:498:

if ((mode == UV_RUN_ONCE && !ran_pending) || mode == UV_RUN_DEFAULT) timeout = uv_backend_timeout(loop);

uv_backend_timeout returns INFINITE. When the next loop then reaches core.c:420 (uv_poll_ex):

success = pGetQueuedCompletionStatusEx(loop->iocp, overlappeds, ARRAY_SIZE(overlappeds), &count, timeout, FALSE);

the program (unsurprisingly) hangs.

Two possible workarounds that fix the issue are:

  1. call uv_stop(uv_default_loop()); after the call to uv_close(), or

  2. in the last line in main.c, replace this:

return uv_run(loop, UV_RUN_DEFAULT);

with

while (0 != uv_run(loop, UV_RUN_ONCE)); return 0;

I am new to libuv. If the above two options are incorrect or ill-advised, what is the correct fix for this?

@nikhilm
Copy link
Owner

nikhilm commented Oct 20, 2016

Thanks for raising this and investigating. joyent/libuv#796 is really old and closed so I'm not sure if that helps directly, but is useful context. @saghul Do you have any thoughts? Am I using uv_close() wrong? Thank you.

@thehoglet
Copy link
Author

@nikhilm No, I don't think you are using uv_close() wrongly. I just took the latest libuv source and rebuilt. The sample code now runs as expected, as do the unit tests for uv_spawn.

As you pointed out, the issue I cited was old and probably irrelevant. I should have been looking here:

History for libuv/src/win/core.c

where a revert took place recently to correct a break.

Thanks for the book. The book and code are very helpful.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants