-
Notifications
You must be signed in to change notification settings - Fork 50
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
adding SIGCHLD signal handler #38
Conversation
You can't just install a Instead, you need to think about when it is safe to run the Specifically, you could unblock it only when you call |
Thanks. I'll try find places need to block the signal.
In what real cases, is
|
The problem with letting the sig_unblock(SIGCHLD)
waitpid()
sig_block(SIGCHLD) if you instead calling |
i.e. main program is not blocking SIGCHLD in most time. |
Just checked some docs on Interruption of signal handlers (please search to locate section titled "Interruption of system calls and library functions by signal handlers"): There are some system calls ( So I guess there may be rare places need to block/unblock SIGCHLD? |
I doesn't make sense to block around read, you need to unblock around the read. |
Ah, I seem to follow you now: you mean we need to block SIGCHLD at the most time, to make Rust safe. |
See vorner/signal-hook#109 for more discussion. The issue of restarting is orthogonal. If you unblock during the read() call and the signal handler executes, the read() will be restarted. |
@godmar Had a glance on the links you provided. Seems it's way complex-er than my expectation :( I may leave this issue/PR open before Rust address it. Personally, I can live with both options below: Handling block/unblock in every corner seems over complex to me. I'll spend more time to see anything proper we have. |
FWIW, I implemented a shell in Rust as well.
ps: I also don't unblock while waiting for a fgjob because I use |
Yeah, I read that, that's nice! Any chance to make it public when you polished it maybe? :)
Good to know. I'll try it. Thanks |
No. I'm contemplating it for an assignment in a class I'm teaching. |
If you code:
then a signal ( |
FWIW, I'm using |
@godmar correct sir. It's a tradeoff of not forking and patching lib Just for curious, do you ever have a Rust demo code that can produce/simulate an asycn-signal-safe issue? |
unblocking before
Here's one in C: https://www.cs.cmu.edu/afs/cs/academic/class/15213-f16/www/code/15-ecf-signals/signaldeadlock.c |
Merging PR now :)
BTW, when using |
Ohh, with Seems I need to change back to sync |
Oh man, I should not use |
try fix #33