Skip to content

Commit 0c3e6f8

Browse files
authored
bug: switch to socket.Dup in eventloop.enroll to enable close-on-exec (#745)
1 parent 58d255f commit 0c3e6f8

File tree

2 files changed

+2
-4
lines changed

2 files changed

+2
-4
lines changed

client_unix.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -210,9 +210,7 @@ func (cli *Client) EnrollContext(c net.Conn, ctx any) (Conn, error) {
210210

211211
var dupFD int
212212
e := rc.Control(func(fd uintptr) {
213-
dupFD, err = unix.Dup(int(fd))
214-
// Set the socket to close-on-exec, so that the socket is closed when the process forks
215-
unix.CloseOnExec(dupFD)
213+
dupFD, err = socket.Dup(int(fd))
216214
})
217215
if err != nil {
218216
return nil, err

eventloop_unix.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ func (el *eventloop) enroll(c net.Conn, addr net.Addr, ctx any) (resCh chan Regi
139139

140140
var dupFD int
141141
err1 := rc.Control(func(fd uintptr) {
142-
dupFD, err = unix.Dup(int(fd))
142+
dupFD, err = socket.Dup(int(fd))
143143
})
144144
if err != nil {
145145
resCh <- RegisteredResult{Err: err}

0 commit comments

Comments
 (0)