-
Notifications
You must be signed in to change notification settings - Fork 205
Socket: Add fd receiving #330
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
28e94ef
to
30db209
Compare
|
||
#include "socket_helpers.h" | ||
|
||
struct cmsghdr* CZ_CMSG_FIRSTHDR(struct msghdr *msg) { |
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.
Only reason is you can't call c macros in swift. So they need to be wrapped in a function we actually can.
let data = try receivedFileHandle.readToEnd() | ||
#expect(data != nil, "Should be able to read from received FD") | ||
|
||
let receivedContent = String(data: data!, encoding: .utf8) |
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.
Just a heads up that a failed #expect
does not end the test. If the above check that data != nil
fails, we will still get to this line, which I'm assuming may panic since data is 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.
Changed to #require!
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.
One small comment on the tests, otherwise LGTM
30db209
to
96e1046
Compare
Via scm_rights. Useful for supporting spawning runc as an OCI runtime as that's how the pty is passed to the client.
96e1046
to
93d120f
Compare
Via scm_rights. Useful for supporting spawning runc as an OCI runtime as that's how the pty is passed to the client.