-
-
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
Rename Process kill methods to signal #8642
Rename Process kill methods to signal #8642
Conversation
Please keep |
I'd also advocate for including something like, |
126f89f
to
efb4f11
Compare
Either way i think it's better that renamed signal method should not have default value, so i removed it. Because of code readability - with process.signal without argument it's very unclear what it does. |
efb4f11
to
9dfa84b
Compare
btw @bcardiff build now fail on some crazy error (in more PRs, not only this):
|
@jan-zajic Yeah, it should be fixed by #8641 |
Co-Authored-By: Benoit de Chezelles <bew@users.noreply.github.com>
@RX14 , @straight-shoota updated according to reviews. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The changes from process.kill
to process.signal Signal::Term
are somewhat counterproductive.
#kill
without arguments is going to become #terminate
in #8536.
I'd suggest to introduce #terminate
and #interrupt
already in this PR. It makes sense because they're portable successors to #kill
and the different uses can be replaced appropriately.
As a bonus, #8536 would truly be only a refactor and neither add nor change any features.
@@ -161,7 +161,7 @@ module Crystal::Playground | |||
@logger.info "Code execution killed (session=#{@session_key}, filename=#{@running_process_filename})." | |||
@process = nil | |||
File.delete @running_process_filename rescue nil | |||
process.kill rescue nil | |||
process.signal(::Signal::TERM) rescue nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This one.
src/process.cr
Outdated
@@ -193,7 +199,7 @@ class Process | |||
$? = process.wait | |||
value | |||
rescue ex | |||
process.kill | |||
process.signal Signal::TERM |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
And this one.
Co-Authored-By: Benoit de Chezelles <bew@users.noreply.github.com>
b75ea9b
to
6149b46
Compare
@straight-shoota I'm all for it. But that assumes we will agree on names of that methods. I still don't know any opinion of others. I'am currently for The options considered so far are (in order gracefully, force shutdown):
So please vote! @straight-shoota, @RX14, @ysbaddaden, @j8r, @Sija, @bew, @bcardiff ping. If I forgot someone please let them know. |
The method to terminate a process is commonly named Let's not bother with an alternative method for graceful termination in this PR. Having separate methods for sending signals and terminating a process is sufficient. If you need graceful termination, you can easily send SIGTERM manually. Whether we should have a dedicated method for this should be a separate discussion to not prolong this PR even more. |
|
The I prefer |
Please let's not use
i like the current naming, and i'd prefer for it to stay |
@RX14 How come? It sends |
I wouldn't worry about that. We need to focus on the best API for the future. |
No, So would you rather have |
Actually this is all too confusing the only interface should be |
@RX14 What's confusing about calling
|
The default should be SIGKILL. Even if it was SIGTERM, that's merely an implementation detail. Simply having everyone call |
We can't use the There must be at least one release where |
How about introducing just |
That sounds reasonable to me.
čt 9. 1. 2020 v 12:34 odesílatel Stephanie Hobbs <notifications@github.com>
napsal:
… How about introducing just #terminate in this PR which sends SIGTERM,
then after #kill is gone, we can add it back sending SIGKILL. So this PR
would just have #signal and #terminate?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#8642?email_source=notifications&email_token=ADLYAP55TGUDT2L6FUSUCF3Q44DULA5CNFSM4KCDMAHKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEIP75LQ#issuecomment-572522158>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADLYAPYXMR7ATM47QVLPKRTQ44DULANCNFSM4KCDMAHA>
.
|
Sure, we can do that. But IMO we don't need a full deprecation cycle just to change the implementation of However I'm still not sure we actually want a |
6149b46
to
ee61fb5
Compare
|
||
process.terminate | ||
process.exists?.should be_true | ||
process.terminated?.should be_false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems like a race condition to me. If the program gets rescheduled between the terminate
call and the exists?
check then this spec will fail. I suspect that running this test in a loop on a loaded machine will already fail.
I'm not sure there's an appropriate way to test this.
This is OK for me to merge except for the race condition in the spec suite |
@jan-zajic Are you still up for this addressing the above comment? |
@straight-shoota ok i look at it in few days |
Was write access given to the branch? Could someone simply remove this spec and merge the PR? |
Mhm, the merge is non-trivial. I have merged it and I'm ready to send a new PR. I think such a PR, if merged, would show me as the primary author, which is not ideal. |
@jan-zajic, could you give some input? |
@oprypin unfortunately i don't have time right now to be able to keep pushing this forward.. So i'm ok with your help, as long as you keep my original work (to some point that make sense), so my original effort will not be wasted.. Last time i put a lot of effort into this, but but we got lost in discussions that led nowhere. |
Closed in favor of #9006 |
As suggested by @ysbaddaden in #8518 and further discussed in draft #8536 rename Process#kill(Signal) to Process#signal(Signal) that we can eventually implement on Windows (if needed) with a deprecation notice. The name kill is confusing as it can means two things - send signal to process, or send signal kill (9) to process when argument ommited. But currently default behavior of kill method without providing signal argument is to send term signal to process (simulates posix behavior of kill command, but we need to remove POSIXisms of apis to become realy portable imho).