-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
patch: v2.9.6 #744
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
patch: v2.9.6 #744
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -211,6 +211,8 @@ func (cli *Client) EnrollContext(c net.Conn, ctx any) (Conn, error) { | |||||||||||||||||||||||||||
| var dupFD int | ||||||||||||||||||||||||||||
| e := rc.Control(func(fd uintptr) { | ||||||||||||||||||||||||||||
| dupFD, err = unix.Dup(int(fd)) | ||||||||||||||||||||||||||||
| // Set the socket to close-on-exec, so that the socket is closed when the process forks | ||||||||||||||||||||||||||||
| unix.CloseOnExec(dupFD) | ||||||||||||||||||||||||||||
|
Comment on lines
213
to
+215
|
||||||||||||||||||||||||||||
| dupFD, err = unix.Dup(int(fd)) | |
| // Set the socket to close-on-exec, so that the socket is closed when the process forks | |
| unix.CloseOnExec(dupFD) | |
| newFD, dupErr := unix.Dup(int(fd)) | |
| if dupErr != nil { | |
| err = dupErr | |
| return | |
| } | |
| dupFD = newFD | |
| // Set the socket to close-on-exec, so that the socket is closed when the process forks | |
| if closeErr := unix.CloseOnExec(dupFD); closeErr != nil { | |
| err = closeErr | |
| } |
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 comment is inaccurate. The close-on-exec flag prevents the file descriptor from being inherited by child processes created via exec() system calls, not fork(). After fork(), file descriptors are inherited by default, but close-on-exec ensures they are closed when exec() is called. The comment should be updated to reflect this distinction.