-
-
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
Bug with signal trap #5830
Comments
Same problem
with code at_exit{ puts "Terminated"}
Signal::INT.trap { exit }
puts "Infinite Loop"
loop { } Expected behavior: Current behavior: The program works with at_exit{ puts "Terminated"}
# Signal::INT.trap { exit }
LibC.signal Signal::INT.value,->(s : Int32){ exit }
puts "Infinite Loop"
loop { } The program exit and print "Terminated" after |
@NIFR91 this is unrelated to the initial issue, and this can't work in Crystal: signals are handled through the event loop; you can't use signal handling to exit a busy loop in crystal, because the busy loop prevents the event loop to resume and handle the signal... Inserting a Note that you need crystal master for the |
We must always close the signal handler pipe after between a fork/exec combination, otherwise a simple `system("")` call prevents further signals from being handled. fixes crystal-lang#5830
Initial issue fixed in ff56d94. |
@ysbaddaden , yes, you are right i didn't think it thoroughly. Maybe in my program i never yield to the event loop, ill check it. |
The problem isn't related to signal handling, well, not exactly. What happens is that Crystal expects That shouldn't affect signals, but... signal handling doesn't happen on the sigaltstack, it's deferred to the event loop —for safety reasons.
|
Duplicate of #2713. |
Code to reproduce this bug (need interactive terminal):
Expected behavior
Print "Canceled by user" and exit the program
Current behavior
Do nothing when you press Ctrl+C
Environment
Tested on MacOS with Crystal 0.24.1 / LLVM 5.0.1
Additional notes
Happens when a child process is created through backslash quote or
system
call.The text was updated successfully, but these errors were encountered: