-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Bypass signal handling in interpreted code #14019
base: master
Are you sure you want to change the base?
Conversation
My comment in #14016 (comment) still stands: What's the point? Do you have a specific use case which this change enables or is it just to get more specs running? |
This allows running shell commands with the interpreter. And I think it's worth it because several github issues were created due to not being able to run shell commands. And fixing more spec tests is a side effect of fixing Process.run As for the issue of handling process signals, I don't think it's used as widely as Process.run This brings a lot of benefits with minimal efforts, so why not? |
c7ae00b
to
7d11346
Compare
This reverts commit 7d11346.
So do you think this is actually a proper bugfix instead of a workaround? |
This is still a workaround with a much smaller impact than #14016. |
|
Hum, that workaround ain't so bad (fake it until you can make it 🤫). It's very inefficient, but if it enables running sub-processes in interpreted mode that would be nice. It currently hangs forever, and I regularly trip on that limitation myself + have a bunch of @HertzDevil you mean something like that? the issue is how to enqueue the suspended fiber, but def wait
{% if flag?(:interpreted) %}
fiber = Fiber.current
exit_code = uninitialized Int32
Thread.new do
LibC.waitpid(pid, pointerof(exit_code), 0)
fiber.current_thread.scheduler.send_fiber(fiber)
end
fiber.reschedule
@channel.send(exit_code)
@channel.close
{% end %}
@channel.receive
end @cyangle if the reenabled specs are calling into Crystal, they may be calling |
I don't think thread works properly when interpreted. There seems to be something wrong with thread local variables. result = ""
thread = Thread.new do
result = "From Thread #{Thread.current}"
end
thread.join
puts "#{Thread.current}: #{result}"
|
I have nothing more to say about this PR. It's still just a hack, but not being able to spawn a child process is very limiting. Threads are indeed unsupported in interpreted code, so we can't use 'em. |
Clearing the milestone because it's not yet read to merge and #14766 might provide a better solution. |
Would this be an acceptable workaround for issue #12241?
It bypasses signal handling in interpreted code and waits until child process terminates.
I also tried forwarding child process exit code to interpreted code via Unix socket, but it doesn't work because it seems like the interpreter fiber never yields to other fibers unless it enters into debugger repl.
@straight-shoota