Skip to content
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

kill(process) should throw an exception rather than return -errno? #18145

Closed
stevengj opened this issue Aug 19, 2016 · 4 comments
Closed

kill(process) should throw an exception rather than return -errno? #18145

stevengj opened this issue Aug 19, 2016 · 4 comments
Assignees
Labels
breaking This change will break code design Design of APIs or of the language itself needs decision A decision on this change is needed needs docs Documentation for this change is required
Milestone

Comments

@stevengj
Copy link
Member

kill(p) currently returns 0 on success, -errno on failure, and -1 if the process was not running. (This is undocumented, by the way.) Shouldn't it throw an exception on failure instead?

@StefanKarpinski StefanKarpinski added breaking This change will break code needs decision A decision on this change is needed design Design of APIs or of the language itself labels Aug 19, 2016
@StefanKarpinski StefanKarpinski added this to the 0.6.0 milestone Aug 19, 2016
@tkelman tkelman added the needs docs Documentation for this change is required label Aug 19, 2016
@tkelman tkelman modified the milestones: 1.0, 0.6.0 Dec 29, 2016
@StefanKarpinski
Copy link
Member

StefanKarpinski commented Jul 27, 2017

Proposal from @Keno:

  • return true/false indicating if the process was running.
  • raise an error if the process failed.

I would add that we'd probably want a force=false keyword argument.

@JeffBezanson proposes renaming to sigsend or sendsignal (or something).

@vtjnash suggested notify as a potential function name.

@JeffBezanson
Copy link
Member

To continue quoting each other, @StefanKarpinski proposes something like kill(p) ensures the process stops in whatever way, e.g. succeeding if the process is already dead, while another function has lower-level signal-sending semantics.

@Keno
Copy link
Member

Keno commented Jul 27, 2017

Final proposal: Throw an error on EPERM and EINVAL, but silently allow ESRCH. On linux we should never get that because the kernel gives success if the process is a zombie. On windows it's racy, so we might get it.

@StefanKarpinski
Copy link
Member

Can't you still get ESRCH if you've already successfully waited on the zombie previously? I.e. this should always work the first time, but could fail if you do it again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking This change will break code design Design of APIs or of the language itself needs decision A decision on this change is needed needs docs Documentation for this change is required
Projects
None yet
Development

No branches or pull requests

5 participants