You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
# server.crrequire"http"
ws_handler =HTTP::WebSocketHandler.new do |ws, ctx|
ws.on_message do |message|
p message
begin
process =Process.new({%if flag?(:win32) %} "hello.exe" {%else%} "./hello" {%end%}, [] of String, output::inherit)
p process
p process.wait
rescue ex
p ex
endendend
server =HTTP::Server.new [ws_handler]
address = server.bind_tcp "127.0.0.1", 55000puts"Listening on http://#{address}"
server.listen
Run server.exe and then client.exe. On Linux Hello world and Process::Status[0] will be printed on the server. On Windows the client returns, but hello.exe gets stuck and server.exe is also stuck waiting on it; subsequent runs of the client will get stuck.
I believe this is also why the playground doesn't work on Windows.
The text was updated successfully, but these errors were encountered:
I believe this is just another consequence of Process#wait being a blocking call, due to LibC.WaitForSingleObject; if the on_message handler blocks the current thread, the HTTP::Server#listen fiber never gets to run, so the child process will never progress.
On POSIX Process#wait is indeed asynchronous and non-blocking, as it relies on SIGCHLD and Channel.
Compile the following sources:
Run
server.exe
and thenclient.exe
. On LinuxHello world
andProcess::Status[0]
will be printed on the server. On Windows the client returns, buthello.exe
gets stuck andserver.exe
is also stuck waiting on it; subsequent runs of the client will get stuck.I believe this is also why the playground doesn't work on Windows.
The text was updated successfully, but these errors were encountered: