1

Context: I want to gracefully close a TCP connection and I want to know if I need to worry about the ENOBUFS error, even if it is rare.

On the web, there are two shutdown() man pages - one is a kernel function and second is a C posix function. The posix man page has an additional return value - it says the function may fail with an error ENOBUFS (shutdown(2), shutdown(3p)). The posix one is 4 years old while the other one was modified 3 months ago.

One the other hand though, when I do the same but through my command line (man version 2.9.4), there is no posix and not even a C library function page, and only the kernel function page, which is 3 years old and does not specify ENOBUFS as an error.

Which one should I prefer? The web man pages or from the terminal?

If there is a function that has man pages for both 2 and 3, which one do I pick? And if the pick depends, what to use in the case of shutdown()? (Should I prefer the latest man page?)

  • These don't seem mutually exclusive to me. Linux offering stronger guarantees than required is still posix-compatible. Assuming both docs are correct, then the decision entirely depends on whether you are targeting linux or posix. –  Jun 13 '21 at 21:23
  • Far from being an expert but: EONOBUFS is not entirely unknown to Linux and indicates a full output queue on the network interface. For example, the Linux man page for `sendto` lists that as a possible error but then states "(Normally, this does not occur in Linux. Packets are just silently dropped when a device queue overflows.)" An orderly shutdown probably involves some outgoing interface traffic which may encounter all the possible send errors, including (or not including?) this one. That it "normally" does not occur on Linux is probably the reason that it is not mentioned in man shutdown. – Peter - Reinstate Monica Jun 14 '21 at 05:51
  • @Peter-ReinstateMonica That doesn't make sense to me. Most errors don't "normally" happen by definition. That's not a valid reason to exlude it from the documentation. –  Jun 16 '21 at 00:57
  • @Frank Bearing in mind that it's a work of volunteers it's conceivable that either the documentation is lacking behind a kernel development or that the two man page authors came to different conclusions about the possibility of that particular error. – Peter - Reinstate Monica Jun 16 '21 at 06:56

0 Answers0