Skip to content

Commit

Permalink
[Inet] Fix setting for O_CLOEXEC
Browse files Browse the repository at this point in the history
The macro O_CLOEXEC is a filedescriptor flag.

The implemention sets the flag O_CLOEXEC as the parameter command given
to function fcntl[1] and causes the call to fcntl to return -1 with
EINVAL.

The flag O_CLOEXEC intends to be set using the command F_SETFD.

This fixes the behaviour by adding the missing command paramete F_SETFD
before the optional argument O_CLOEXEC.

[1]: https://man7.org/linux/man-pages/man2/fcntl.2.html
  • Loading branch information
gportay committed Apr 25, 2024
1 parent fb43d1a commit 7da2b18
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/inet/InetInterface.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ int GetIOCTLSocket()
#endif
{
s = socket(AF_INET, SOCK_STREAM, 0);
fcntl(s, O_CLOEXEC);
fcntl(s, F_SETFD, O_CLOEXEC);
}

if (!__sync_bool_compare_and_swap(&sIOCTLSocket, -1, s))
Expand Down

0 comments on commit 7da2b18

Please sign in to comment.