-
Notifications
You must be signed in to change notification settings - Fork 17.8k
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
os: export errFinished as ErrProcessDone #39444
Comments
It returns If you really need to distinguish these cases, which means that you are already doing Unix-specific things, I recommend that you use |
Thank you for answer, that's all make a point. I wish to use os.signal, because it already have lot's of useful logic like rw-locks and pid checking. If I use raw Are there any disadvantages from making errFinished public? |
OK, I'll turn this into a proposal to export |
I'm a little hesitant about exporting errFinished under that name, since it's not a general "something finished". I'm also having a hard time coming up with a better name. The wait man page says "wait for process termination" so we could use ErrProcessTerminated but that's not in keeping with the other names in os (too long, and also too specific). @ianlancetaylor pointed out maybe we could use ErrNotExist, or perhaps we could keep using errFinished but make errors.Is(errFinished, ErrNotExist) true. Thoughts? |
As I noted last week, it seems like the least API surface would be to make errFinished be errors.Is(..., ErrNotExist). Retitled to that. Does anyone object to that? |
Does that mean I'd expect signal and other process-related APIs to return errors specific to processes. |
Thinking about method calls in grammatical terms, I expect
The proposed usage would be consistent with that, but requires the reader to treat the name of the method as the verb (as they should, but may not always do).
On the other hand, the error text of I think a more general standardized error for “[direct object] does not exist” could be useful, but I agree that, because of its specific text, |
@bcmills, it's not as clear cut as you say. I wouldn't be surprised if f.Stat() could return ErrNotExist in certain cases (those cases do not include "local file on Unix"). In any event, it's likely clear to the caller that the signal itself does exist. On the other hand, ErrNotExist.String() is "file does not exist", so that's a show-stopper. ErrProcessDone? (at least we have established Done in context, and it's shorter than Finished) |
No responses for ErrProcessDone, but it seems like people are in general OK with exporting the error. |
No change in consensus, so accepted. |
Change https://golang.org/cl/242998 mentions this issue: |
Change https://golang.org/cl/274477 mentions this issue: |
For #39444 For #40700 Fixes #42908 Change-Id: Idae35adecd79e9d7d207f9d78cb009a980e5c8a9 Reviewed-on: https://go-review.googlesource.com/c/go/+/274477 Trust: Tobias Klauser <tobias.klauser@gmail.com> Reviewed-by: Russ Cox <rsc@golang.org>
In Linux, kill() can return there possible errors:
[EINVAL]
The value of the sig argument is an invalid or unsupported signal number.
[EPERM]
The process does not have permission to send the signal to any receiving process.
[ESRCH]
No process or process group can be found corresponding to that specified by pid.
This is how os.signal function works in Go:
go/src/os/exec_unix.go
Line 64 in fca286b
What it returns private errFinished instead of public ESRCH ?
Because of that I can't write some custom logic like this:
It's okay that this error can have custom name, but why it private? Why errFinished, but not ErrFinished?
The text was updated successfully, but these errors were encountered: