macos 27 - EDOM error from setsockopt() for SO_LINGER socket option for values greater than 32767

On macos 27, there appears to be a change in the setsockopt() implementation for the SO_LINGER option. It looks like the implementation now imposes a different maximum limit on the value that is accepted for linger. Consider the trivial attached C program.

Rename it from main.c.txt to main.c. Compiling it (using clang main.c) and running it (using ./a.out), on older versions of macos (like 26.x), it returns:

-----------------------
MacOS version: 26.7.1
Kernel version: Darwin Kernel Version 25.6.0: Tue Aug 18 17:49:13 PDT 2026; root:xnu-12377.161.15.700.19~2/RELEASE_ARM64_T6000
-----------------------
SUCCESS - set SO_LINGER to value 10
SUCCESS - set SO_LINGER to value 42
SUCCESS - set SO_LINGER to value 1024
SUCCESS - set SO_LINGER to value 32767
SUCCESS - set SO_LINGER to value 32768
SUCCESS - set SO_LINGER to value 65535
SUCCESS - set SO_LINGER to value 65536
SUCCESS - set SO_LINGER to value 65578

However, on macos 27, this now fails with EDOM error ("Numerical argument out of domain") for values greater than 32767:

-----------------------
MacOS version: 27.0.1
Kernel version: Darwin Kernel Version 27.0.0: Tue Aug 11 21:02:16 PDT 2026; root:xnu-13432.1.9~1/RELEASE_ARM64_T8112
-----------------------
SUCCESS - set SO_LINGER to value 10
SUCCESS - set SO_LINGER to value 42
SUCCESS - set SO_LINGER to value 1024
SUCCESS - set SO_LINGER to value 32767
FAILURE - failed to set SO_LINGER to value 32768, reason: Numerical argument out of domain
FAILURE - failed to set SO_LINGER to value 65535, reason: Numerical argument out of domain
FAILURE - failed to set SO_LINGER to value 65536, reason: Numerical argument out of domain
FAILURE - failed to set SO_LINGER to value 65578, reason: Numerical argument out of domain

I'm guessing this is an intentional change, but I wanted to confirm nonetheless. Should the documentation of SO_LINGER and SO_LINGER_SEC socket options, in man setsockopt, mention the acceptable value range for them?

Answered by DTS Engineer in 907689022

Yep, definitely a deliberate change (r. 174844817).

Should the documentation … mention the acceptable value range for them?

Should questions are a hard for me to answer (-: so my response is gonna be: If you think that should be the case, I encourage you to file a bug against that man page.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Accepted Answer

Yep, definitely a deliberate change (r. 174844817).

Should the documentation … mention the acceptable value range for them?

Should questions are a hard for me to answer (-: so my response is gonna be: If you think that should be the case, I encourage you to file a bug against that man page.

Share and Enjoy
—
Quinn “The Eskimo!” @ Developer Technical Support @ Apple
let myEmail = "eskimo" + "1" + "@" + "apple.com"

Yep, definitely a deliberate change (r. 174844817).

Thank you for confirming, Quinn.

Should the documentation … mention the acceptable value range for them?

Should questions are a hard for me to answer (-: so my response is gonna be: If you think that should be the case, I encourage you to file a bug against that man page.

I think it will be useful. I filed it as a suggestion, id is FB25031577

macos 27 - EDOM error from setsockopt() for SO_LINGER socket option for values greater than 32767
 
 
Q