-
-
Notifications
You must be signed in to change notification settings - Fork 59
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
Duplicate SIGINT sent to suprocess on Unix based systems #189
Comments
(Tested both changes locally and they work as expected.) |
In case it's helpful, here's a link to the the proc_runner script I mention above. |
Hi @biasedbit, thanks for the interesting issue. Option B does seem preferable, except that it does in practice break usage of poe with some CLI tools one could want to calls via a task, some contrived examples: This makes me think there should be a task option to enable it, something like Of course for consistency adding the preexec_fn keyword argument should be done by editing the popen_kwards dictionary above, and a new option would require a test and some documentation to release. Incidentally setting the use_exec option to you task might be a valid workaround for you? Also a comment on the example task definition from your script, normally including |
I'll take a stab at it over the next couple of days. Cheers! |
Hey @nat-n, didn't get a chance to work on this over the holidays but picking this up today — just checking in with you to make sure we don't both end up working on it at the same time. |
@biasedbit all yours :) |
Looking a bit more carefully into this, turns out I'm going to go ahead and close this; thanks for jumping in so quick and talking it through — and for building this really incredible tool 🙌 |
I was putting together a simple python script to manage multiple background processes (kinda like what's being discussed in #24). This script is invoked by poe (poe → proc_manager → p1, p2, ..., pN) and while working on signal interception & forwarding, I noticed hitting ctrl+c results in 2 SIGINTs being received by my proc_manager.
This SO post has a great detailed explanation of why this happens; the tl:dr is ctrl+c → end-of-text char to tty → tty sends SIGINT to all processes in foreground process group.
Since the poe task subprocess is not detached from poe's process group (e.g. by adding a
preexec_fn=os.setpgrp
orprocess_group=0
arg toPopen
call here) and there's a signal handler to explicitly forward SIGINT to subprocs here, we end up with two SIGINTs being sent to the subprocs.Only noticed this because in my use case I'm trying to handle the first SIGINT differently from subsequent ones (call
subproc.terminate()
first, thensubproc.kill()
).Happy to send a PR; proposed change are either A:
Or B:
A has the downside of not forwarding an explicit SIGINT being sent to poe (e.g. via
kill -INT <poe_pid>
).B I don't think there's a downside on Unix? I've opted for B in my proc_manager script.
lmk what you think and I'll send the change request.
The text was updated successfully, but these errors were encountered: