-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Introduce/use internal/linux pkg to handle EINTR and error wrapping #4697
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
Conversation
The alternative to this is to create something like
|
@rata WDYT? The motivation here is,
PS In an ideal world, I wish for a package like this ("wrapped unix") to already exist. |
@kolyshkin Makes sense to me! This is definitely some direction I thought to explore after merging the other PR. When playing with our openat2 yesterday (to address your comment), I was thinking of thin wrappers that just do this but I wasn't sure it would be liked because of the existing openat wrapper that was doing more stuff. But you went ahead and did both things at once. Perfect :) |
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.
LGTM, thanks!
internal/linux/linux.go
Outdated
return os.NewSyscallError("dup3", retryOnEINTR(func() error { | ||
return unix.Dup3(oldfd, newfd, flags) |
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.
nit: I think splitting this in more lines can be clearer. The functio that takes several params, the third of which is another function that takes a function param that is defined inline is a little bit too much, IMHO.
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.
Fixed this and also Sendmsg in the same way.
This package is to provide unix.* wrappers to ensure that: - they retry on EINTR; - a "rich" error is returned on failure. A first such wrapper, Sendmsg, is introduced. Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
Drop the libcontainer/system/exec, and use the linux.Exec instead. Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
Signed-off-by: Kir Kolyshkin <[email protected]>
Inspired by #4680. The idea here is hide the retry-on-EINTR functionality inside a package, as well as provide error wrappers.
A few more wrappers is to be added.
PS I'm not sure about the package name, perhaps
sys
oruunix
is a better name. I want something short and simple.