]> git.ipfire.org Git - thirdparty/man-pages.git/commitdiff
dup.2: ERRORS: Add ENOMEM
authorLevi Zim <rsworktech@outlook.com>
Fri, 27 Sep 2024 06:52:29 +0000 (14:52 +0800)
committerAlejandro Colomar <alx@kernel.org>
Fri, 1 Nov 2024 12:39:31 +0000 (13:39 +0100)
dup2(2) could return ENOMEM under extreme condition.  For example, when
sysctl fs.nr_open=2147483584, and RLIMIT_NOFILE is also 2147483584.
The following program fails with ENOMEM:

int
main(void)
{
if (dup2(0, 2000000000) == -1)
err(1, "dup2");
return 0;
}

This ENOMEM comes from an allocation error here:
<https://elixir.bootlin.com/linux/v6.1/source/mm/util.c#L596>

ENOMEM is already documented for open(2).

Signed-off-by: Levi Zim <rsworktech@outlook.com>
[alx: tweak commit message]
Signed-off-by: Alejandro Colomar <alx@kernel.org>
man/man2/dup.2

index ee964a827ca062d90419c7d39f457de270d42ca3..719f0ae9e78165733cbe607bbf8a803a5d0943b4 100644 (file)
@@ -197,6 +197,9 @@ The per-process limit on the number of open file descriptors has been reached
 .B RLIMIT_NOFILE
 in
 .BR getrlimit (2)).
+.TP
+.B ENOMEM
+Insufficient kernel memory was available.
 .SH STANDARDS
 .TP
 .BR dup ()