Skip to content

docs(debt): record the dup, dup2 and _dup2 results on firmware 11.60 - #22734

Merged
oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libkernel-dup-family-console-1160
Nov 18, 2026
Merged

oneandonlydean merged 1 commit into
boykopovar:mainfrom
xXPBSXx:docs/libkernel-dup-family-console-1160

Conversation

@xXPBSXx

@xXPBSXx xXPBSXx commented Nov 18, 2026

Copy link
Copy Markdown
Contributor

What

The dup and dup2 entry in docs/dev/debt/libkernel.md says that the descriptor numbers come from the host table and that "the errno values for descriptor exhaustion are not verified against the console"; the _dup2 entry in docs/dev/debt/libkernel_sys.md ends with "console behaviour is unverified". A probe has now called dup, dup2 and _dup2 in libkernel.sprx from a payload process on firmware 11.60, on a plain file it created. The pull request replaces those sentences through one debt fragment with a section for each file, as the contribution rules ask; no code changes.

dup of the file descriptor returned the next number (case 2.1, line 5), and dup(-1) and dup(999) returned -1 with errno 9 (EBADF, 2.2 and 2.3, lines 6 and 7). dup2 returned its target for 50, for the descriptor itself and again for 50 (3.1 to 3.3, lines 8 to 10), and EBADF for the sources -1 and 999 and for the targets -1, 1000000 and 0x7fffffff (3.4 to 3.8, lines 11 to 15). _dup2 gave the same eight results (4.1 to 4.8, lines 16 to 23). A duplicate shared the file offset with the original (5.1, line 24), did not inherit the close-on-exec flag that the original had (5.2, line 25), and neither did the target of dup2 (5.3, line 26); fcntl with F_DUPFD_CLOEXEC returned -1 with errno 45 (EOPNOTSUPP, 5.4, line 27), as the F_DUPFD_CLOEXEC entry already says for files, and a write through the duplicate worked after the original was closed (5.5, line 28). Opening the file in a loop failed with errno 24 (EMFILE) after 632 descriptors, while getdtablesize() returned 12555 (6.1, line 29); a dup at that point still succeeded and returned 640 (6.2, line 30), and all 632 descriptors were closed again (6.3, line 31).

When the code is read, AnyPS5 answers the first cases the same way: dup_nid_postfix (libkernel/File/src/Stdio.cpp, lines 1021 to 1038) returns EBADF for a negative descriptor (line 1023) and otherwise asks the host, and dup2_nid_postfix (lines 1040 and following) returns EBADF for a negative source or target (line 1041); _dup2_nid_postfix (libkernel_sys/AdditionalExports.cpp, lines 224 to 226) calls GuestDup2_nid_no_patch (lines 220 to 222), which calls dup2_nid_postfix. The other cases (999, the large targets, the offset, the close-on-exec flag) depend on the host calls and were not compared, and the emulator was not run for this pull request. The limit differs: AnyPS5 fails with EMFILE at the host's table (the getrlimit entry describes it), not after 632 descriptors, so a program that opens plain files until EMFILE reaches a different count here. This pull request records that and changes no behaviour, because the console's limit was measured only for plain files in one payload process.

Not measured: descriptors of sockets, pipes, kqueues and shared memory, dup2 onto descriptors 0 to 2 (the probe never does it), the limit of other descriptor types, and a title process.

Tested

Measured on a PS5 with firmware 11.60 (kernel_get_fw_version 0x11600005), from a homebrew payload process (ps5-payload-sdk v0.45, elfldr) that loads libkernel.sprx and takes dup, dup2 and _dup2 with dlsym (line 3 shows all three were found), on 2026-11-18 at 02:36 UTC. A title process may differ. The cases are 0 to 9, lines 2 to 32 of the raw output in the first comment.

Call PS5 payload process, firmware 11.60 AnyPS5 main (code read, not run) in the entry
dup(-1), dup(999) EBADF (lines 6, 7) EBADF for -1 (line 1023); 999 by the host call now stated
dup2 source -1 or 999, target -1, 1000000, 0x7fffffff EBADF (lines 11 to 15) EBADF for a negative one (line 1041); the rest by the host call now stated
_dup2, same eight cases same as dup2 (lines 16 to 23) calls dup2 through GuestDup2_nid_no_patch now stated
duplicate: offset, close-on-exec flag offset shared, flag not inherited (lines 24 to 26) not compared now stated
open of a plain file until it fails EMFILE after 632; getdtablesize 12555 (line 29) EMFILE at the host table now stated (differs)

tools/check_conventions.py --base upstream/main passes with no error and no warning (the two entries are now 952 and 644 characters, up from 646 and 497). This is a documentation change, so no test was added or run, and no GPU test applies. Not tested: the emulator against these calls, a title process, other firmware, and the cases listed above as not measured.

Overlap: the other open pull requests that change the file of this branch (the fragment docs/dev/debt/changes/docs-libkernel-dup-family-console-1160.md, a new file), core/libs/prx/libkernel/File/src/Stdio.cpp, core/libs/prx/libkernel_sys/AdditionalExports.cpp or core/libs/tests/GuestDup.cpp, which the entries and the text name, or the two debt entries it changes, found by reading the changed files of all 1775 open pull requests at about 05:02 to 05:16 UTC, by reading what they change in docs/dev/debt/libkernel.md, docs/dev/debt/libkernel_sys.md and the fragments under docs/dev/debt/changes/ for dup, dup2 and _dup2, and by searching their titles and branch names for the same names (see below), were test-merged on 2026-11-18 at about 05:19 UTC against main a940e04517f together with this head; the branch is based on 092a1df132b, an ancestor of it, merges into main without a conflict, and tools/debt_fold.py --check applies the fragment to the libkernel and libkernel_sys debt files of main without an error (checked without the fragment docs-nkwebkit-drop-readded-count-lines.md, which already fails on main against the libSceNKWebKit debt file and is not part of this change), each of the two texts the change names occurs in exactly one entry, and no other fragment changes those entries. Eighty-two pull requests list one of the code files or a debt file that names these functions, most of them docs/dev/debt/libkernel.md for other entries; as this branch adds only a fragment, none of them conflicts only with this change. Three touch the functions in code: #22191 (share a ksem semaphore across dup, dup2 and ...) changes dup in Stdio.cpp and carries its own fragment for the ksem entry, not for the dup and dup2 entry, and may change what the entry describes when it lands; #18190 changes the call in GuestDup2_nid_no_patch, which _dup2 uses, from dup2_nid_postfix to dup2_nid_no_patch, which does not change the answers recorded here; and #7121 carries the dup2 code lines as unchanged context. The other title hits (#19044, #19024 and #17621 for EC_POINT_dup and RSAPublicKey_dup, #18740 for a test of the web library) are about other functions. None of them changes a line of the two entries of this branch. The merged result was not built or run; this is a documentation change.

Checklist

  • Based on current main; no other open PR implements the same functions
  • One topic per PR; follow-ups go in a new PR
  • No comments in code except technical debt
  • Unimplemented paths throw (NotImplemented_nid_no_patch); silent stubs are listed under Silent stubs in their library's technical debt file
  • No notes, investigation .md files or images added to the repository (attach them to this PR)
  • New third-party code is a submodule built from source
  • Generic behaviour, not specific to one title
  • Depends on: none
  • Fixes: none
  • Unblocks: none
  • GPUs tested: n/a (documentation only)
  • AI-assisted: yes

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@xXPBSXx

xXPBSXx commented Nov 18, 2026

Copy link
Copy Markdown
Contributor Author

Probe source (built with ps5-payload-sdk v0.45; PROBE_BUILD is the first 12 hex digits of the source's SHA-256, da625aa7b336) and its raw output from the run on 2026-11-18 at 02:36 UTC. The clock in the PROBE line is the console's own clock. The probe loads libkernel.sprx, takes dup, dup2 and _dup2 with dlsym, makes a file in its own folder and uses only descriptors of that file (no socket, no other descriptor type and never a dup2 onto 0, 1 or 2): dup, dup2 and _dup2 with valid and invalid sources and targets, the shared offset and the close-on-exec flag of a duplicate, and an exhaustion test that opens the file in a loop (at most 4096 descriptors or 5 seconds, stopping at the first failure), calls dup at that point and closes every descriptor it opened. Every call is guarded against signals and by a self limit; the file and the folder are removed at the end. An internal probe number in the header comment was removed; the code is unchanged, and the build ID is the hash of the original file.

probe.c
/* dup, dup2 and _dup2 edge cases and descriptor exhaustion with plain files, payload process, firmware 11.60 (debt libkernel.md
   entry: dup and dup2 throw for the combinations they do not model, dup2 of a guest socket onto descriptors 0 to 2; the numbers come from
   the host descriptor table like those of files; the errno values for descriptor exhaustion are not verified against the console; debt
   libkernel_sys.md _dup2 entry: follows FreeBSD 11.4's _dup2 and POSIX.1-2008 dup2, forwards to libkernel's dup2, returning the target
   descriptor or setting errno and returning -1; console behaviour unverified). Prototypes: int dup(int), int dup2(int, int), _dup2 like
   dup2. The three are looked up with dlsym (libkernel.sprx first, then the global scope); a missing export is the result for its cases.
   Only descriptors of the regular file f1 in the probe's own subdirectory /data/anyps5_probe/n2_14 are used: no socket, no kqueue, no
   semaphore descriptor and never a dup2 onto descriptor 0, 1 or 2. Cases: dup of the file descriptor (the number as small or not), dup2
   to 50, dup2 onto itself, dup2 to 50 again, dup2 with the source -1 and 999 and the target -1, 1000000 and 0x7fffffff, dup(-1), the
   values of getdtablesize() and sysconf(_SC_OPEN_MAX); the same cases through _dup2; exhaustion: open f1 in a loop (at most 4096 descriptors,
   at most 5 seconds, stopping at the first failure): the number opened and errno at the stop, the number against getdtablesize(), then a dup
   at the full limit (errno), then every descriptor opened is closed; shared state: after a write on f, dup g shares the file offset, close
   f then a write through g works, the close-on-exec flag of the duplicate of a descriptor that has it set (dup, dup2 and fcntl
   F_DUPFD_CLOEXEC). Cleanup is mandatory: every descriptor opened is closed and f1 and the directory are removed. Nothing is sent. */
#include <dlfcn.h>
#include <errno.h>
#include <pthread.h>
#include <signal.h>
#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include <time.h>
#include <unistd.h>
#include <ps5/kernel.h>   /* only for kernel_get_fw_version() */

#ifndef PROBE_NAME
#define PROBE_NAME "unnamed"
#endif
#ifndef PROBE_BUILD
#define PROBE_BUILD "unbuilt"
#endif
/* Self limit: the runner can only close the connection, it cannot end the process on the console, so the probe ends
   itself after PROBE_MAX_S seconds at the latest (set by the build script). */
#ifndef PROBE_MAX_S
#define PROBE_MAX_S 50
#endif

static volatile int g_handle = -1;
static int (*volatile g_setmargins)(int, int, int) = 0; /* unused here */
static void reset_rate(void) {
  if (g_setmargins && g_handle >= 0) g_setmargins(g_handle, 0, 0);
}

static void probe_alarm(int sig) {
  static const char msg[] = "TIMEOUT\tprobe self limit\n";
  (void)sig;
  (void)!write(1, msg, sizeof msg - 1);
  reset_rate();
  _exit(124);
}

/* Watchdog thread: alarm()/SIGALRM does not help when the main thread hangs in a blocking system call or IPC. The
   thread sleeps PROBE_MAX_S seconds, writes TIMEOUT with write() and ends the process with _exit(124). alarm() stays
   as a second safeguard. */
static void* probe_watchdog(void* arg) {
  static const char msg[] = "TIMEOUT\tprobe watchdog thread\n";
  unsigned left = PROBE_MAX_S;
  (void)arg;
  while (left) left = sleep(left);
  (void)!write(1, msg, sizeof msg - 1);
  reset_rate();
  _exit(124);
  return 0;
}

static void probe_watchdog_start(void) {
  pthread_t t;
  if (pthread_create(&t, 0, probe_watchdog, 0) == 0) pthread_detach(t);
}

static int cases = 0;

static void probe_header(void) {
  char utc[32];
  time_t now = time(0);
  probe_watchdog_start();
  struct tm tmv;
  gmtime_r(&now, &tmv);
  strftime(utc, sizeof utc, "%Y-%m-%dT%H:%M:%SZ", &tmv);
  printf("PROBE\t%s\tfw=0x%08x\tbuild=%s\tpid=%d\tutc=%s\n", PROBE_NAME, kernel_get_fw_version(), PROBE_BUILD,
         getpid(), utc);
  fflush(stdout);
}

static void probe_case(const char* id, const char* call, long ret, int err, const char* extra) {
  printf("CASE\t%s\t%s\t%ld\t%d\t%s\n", id, call, ret, err, extra ? extra : "-");
  fflush(stdout);
  cases++;
}

static void probe_end(void) {
  printf("END\t%d\n", cases);
  fflush(stdout);
}



#include <fcntl.h>
#include <limits.h>
#include <sys/stat.h>
#include <time.h>

typedef int (*fn_dup)(int);
typedef int (*fn_dup2)(int, int);

static int fds[4200];
static fn_dup f_dup;
static fn_dup2 f_dup2, f_dup2u;

static void fault(int sig) {
  static const char msg[] = "FAULT\tsignal in the call\n";
  (void)sig;
  (void)!write(1, msg, sizeof msg - 1);
  _exit(125);
}

static void res(const char* id, const char* label, int r, int e) {
  char extra[100];
  snprintf(extra, sizeof extra, "rc=%d errno=%d", r, e);
  probe_case(id, label, r, e, extra);
}

static void dup2_cases(const char* tag, fn_dup2 d2, int f, int base) {
  char id[16], label[100];
  int r;
  struct { int from, to; const char* what; } c[] = {
      {0, 50, "dup2(f, 50)"}, {0, 0, "dup2(f, f)"}, {0, 50, "dup2(f, 50) again"}, {-1, 5, "dup2(-1, 5)"}, {999, 5, "dup2(999, 5)"},
      {0, -1, "dup2(f, -1)"}, {0, 1000000, "dup2(f, 1000000)"}, {0, 0x7fffffff, "dup2(f, 0x7fffffff)"}};
  for (int i = 0; i < 8; ++i) {
    int from = c[i].from == 0 && i != 1 ? f : (i == 1 ? f : c[i].from);
    int to = i == 1 ? f : c[i].to;
    errno = 0;
    r = d2(from, to);
    int e = errno;
    snprintf(id, sizeof id, "%s.%d", tag, i + 1);
    snprintf(label, sizeof label, "%s %s", base ? "_dup2" : "dup2", c[i].what);
    char extra[120];
    snprintf(extra, sizeof extra, "rc=%d errno=%d equals_target=%d", r, e, r == to);
    probe_case(id, label, r, e, extra);
    if (r >= 0 && r != f && r > 2) close(r);
  }
}

int main(void) {
  signal(SIGALRM, probe_alarm);
  signal(SIGSEGV, fault);
  signal(SIGBUS, fault);
  alarm(PROBE_MAX_S);
  probe_header();
  char extra[220], id[16], label[100];

  errno = 0;
  void* lk = dlopen("libkernel.sprx", RTLD_LAZY);
  probe_case("0", "load libkernel.sprx", lk ? 0 : -1, errno, lk ? "loaded" : dlerror());
  if (!lk) { probe_end(); return 0; }
  f_dup = (fn_dup)dlsym(lk, "dup");
  f_dup2 = (fn_dup2)dlsym(lk, "dup2");
  f_dup2u = (fn_dup2)dlsym(lk, "_dup2");
  const char* where_u = "libkernel";
  if (!f_dup2u) { f_dup2u = (fn_dup2)dlsym(RTLD_DEFAULT, "_dup2"); where_u = "global"; }
  snprintf(extra, sizeof extra, "dup=%d dup2=%d _dup2=%d (_dup2 found in %s)", f_dup != 0, f_dup2 != 0, f_dup2u != 0, f_dup2u ? where_u : "none");
  probe_case("0b", "dlsym of the functions", 0, 0, extra);
  if (!f_dup && !f_dup2 && !f_dup2u) { probe_end(); return 0; }

  errno = 0;
  int mk = mkdir("/data/anyps5_probe/n2_14", 0700);
  int mke = errno;
  int f = open("/data/anyps5_probe/n2_14/f1", O_CREAT | O_RDWR | O_EXCL, 0600);
  int fe = errno;
  if (f < 0) {
    snprintf(extra, sizeof extra, "mkdir_rc=%d (errno %d) open_f1 errno %d", mk, mke, fe);
    probe_case("1", "set up f1", -1, 0, extra);
    goto cleanup;
  }
  snprintf(extra, sizeof extra, "f1_fd_ge_3=%d getdtablesize=%d sysconf_open_max=%ld", f > 2, getdtablesize(), (long)sysconf(_SC_OPEN_MAX));
  probe_case("1", "set up f1; descriptor table limits", 0, 0, extra);

  /* b) dup, dup2 */
  if (f_dup) {
    errno = 0;
    int g = f_dup(f);
    int e = errno;
    snprintf(extra, sizeof extra, "rc_ge_0=%d is_f_plus_1=%d errno=%d", g >= 0, g == f + 1, e);
    probe_case("2.1", "dup(f)", g, e, extra);
    if (g >= 0) close(g);
    errno = 0;
    g = f_dup(-1);
    res("2.2", "dup(-1)", g, errno);
    errno = 0;
    g = f_dup(999);
    res("2.3", "dup(999)", g, errno);
  }
  if (f_dup2) dup2_cases("3", f_dup2, f, 0);
  if (f_dup2u) dup2_cases("4", f_dup2u, f, 1);

  /* d) shared state */
  if (f_dup) {
    int g = -1;
    (void)!write(f, "a", 1);
    g = f_dup(f);
    if (g >= 0) {
      off_t of = lseek(f, 0, SEEK_CUR), og = lseek(g, 0, SEEK_CUR);
      snprintf(extra, sizeof extra, "offset_f_equals_g=%d offset_is_1=%d", of == og, of == 1);
      probe_case("5.1", "dup(f) shares the file offset", 0, 0, extra);
      fcntl(f, F_SETFD, FD_CLOEXEC);
      int h = f_dup(f);
      int hf = h >= 0 ? fcntl(h, F_GETFD) : -1;
      snprintf(extra, sizeof extra, "f_flag=%d dup_flag=%d", fcntl(f, F_GETFD), hf);
      probe_case("5.2", "close-on-exec flag of f and of dup(f)", 0, 0, extra);
      if (h >= 0) close(h);
      if (f_dup2) {
        int k = f_dup2(f, 51);
        snprintf(extra, sizeof extra, "rc=%d flag_of_target=%d", k, k >= 0 ? fcntl(k, F_GETFD) : -1);
        probe_case("5.3", "dup2(f, 51) with the flag set on f", k, 0, extra);
        if (k >= 0 && k != f) close(k);
      }
      int m = fcntl(f, F_DUPFD_CLOEXEC, 52);
      snprintf(extra, sizeof extra, "rc_ge_52=%d flag_of_result=%d errno=%d", m >= 52, m >= 0 ? fcntl(m, F_GETFD) : -1, m < 0 ? errno : 0);
      probe_case("5.4", "fcntl(f, F_DUPFD_CLOEXEC, 52)", m, 0, extra);
      if (m >= 0) close(m);
      fcntl(f, F_SETFD, 0);
      /* close f's twin: write through g after closing the original f is checked on a fresh pair */
      int f2 = f_dup(f);
      if (f2 >= 0) {
        close(f);
        f = -1;
        ssize_t w = write(f2, "b", 1);
        snprintf(extra, sizeof extra, "write_rc=%zd", w);
        probe_case("5.5", "write through the duplicate after the original is closed", (int)w, 0, extra);
        f = f2;
      }
      close(g);
    }
  }

  /* c) exhaustion, last */
  if (f >= 0) {
    int n = 0, e = 0;
    struct timespec t0, t1;
    clock_gettime(CLOCK_MONOTONIC, &t0);
    int timed_out = 0;
    for (; n < 4096; ++n) {
      errno = 0;
      int x = open("/data/anyps5_probe/n2_14/f1", O_RDONLY);
      if (x < 0) { e = errno; break; }
      fds[n] = x;
      clock_gettime(CLOCK_MONOTONIC, &t1);
      if ((t1.tv_sec - t0.tv_sec) >= 5) { timed_out = 1; n++; break; }
    }
    snprintf(extra, sizeof extra, "opened=%d errno_at_stop=%d stopped_by_failure=%d stopped_by_limit_4096=%d stopped_by_time=%d getdtablesize=%d", n, e,
             n < 4096 && !timed_out, n >= 4096, timed_out, getdtablesize());
    probe_case("6.1", "open(f1) in a loop up to 4096 descriptors or 5 seconds", n, e, extra);
    if (f_dup && n < 4096 && !timed_out) {
      errno = 0;
      int g = f_dup(f);
      int ge = errno;
      snprintf(extra, sizeof extra, "rc=%d errno=%d", g, ge);
      probe_case("6.2", "dup(f) at the full limit", g, ge, extra);
      if (g >= 0) close(g);
    }
    int closed = 0;
    for (int i = 0; i < n; ++i) if (close(fds[i]) == 0) closed++;
    snprintf(extra, sizeof extra, "closed=%d of %d", closed, n);
    probe_case("6.3", "close every descriptor opened by the loop", closed == n ? 0 : -1, 0, extra);
  }

cleanup:
  {
    if (f >= 0) close(f);
    int c1 = unlink("/data/anyps5_probe/n2_14/f1");
    int c2 = rmdir("/data/anyps5_probe/n2_14");
    snprintf(extra, sizeof extra, "unlink_f1=%d rmdir_dir=%d", c1, c2);
    probe_case("9", "cleanup: close and remove f1 and the directory", c2, 0, extra);
  }
  probe_end();
  return 0;
}
stdout
PROBE	dup_family	fw=0x11600005	build=da625aa7b336	pid=258	utc=2026-11-18T04:18:01Z
CASE	0	load libkernel.sprx	0	2	loaded
CASE	0b	dlsym of the functions	0	0	dup=1 dup2=1 _dup2=1 (_dup2 found in libkernel)
CASE	1	set up f1; descriptor table limits	0	0	f1_fd_ge_3=1 getdtablesize=12555 sysconf_open_max=13952
CASE	2.1	dup(f)	8	0	rc_ge_0=1 is_f_plus_1=1 errno=0
CASE	2.2	dup(-1)	-1	9	rc=-1 errno=9
CASE	2.3	dup(999)	-1	9	rc=-1 errno=9
CASE	3.1	dup2 dup2(f, 50)	50	0	rc=50 errno=0 equals_target=1
CASE	3.2	dup2 dup2(f, f)	7	0	rc=7 errno=0 equals_target=1
CASE	3.3	dup2 dup2(f, 50) again	50	0	rc=50 errno=0 equals_target=1
CASE	3.4	dup2 dup2(-1, 5)	-1	9	rc=-1 errno=9 equals_target=0
CASE	3.5	dup2 dup2(999, 5)	-1	9	rc=-1 errno=9 equals_target=0
CASE	3.6	dup2 dup2(f, -1)	-1	9	rc=-1 errno=9 equals_target=1
CASE	3.7	dup2 dup2(f, 1000000)	-1	9	rc=-1 errno=9 equals_target=0
CASE	3.8	dup2 dup2(f, 0x7fffffff)	-1	9	rc=-1 errno=9 equals_target=0
CASE	4.1	_dup2 dup2(f, 50)	50	0	rc=50 errno=0 equals_target=1
CASE	4.2	_dup2 dup2(f, f)	7	0	rc=7 errno=0 equals_target=1
CASE	4.3	_dup2 dup2(f, 50) again	50	0	rc=50 errno=0 equals_target=1
CASE	4.4	_dup2 dup2(-1, 5)	-1	9	rc=-1 errno=9 equals_target=0
CASE	4.5	_dup2 dup2(999, 5)	-1	9	rc=-1 errno=9 equals_target=0
CASE	4.6	_dup2 dup2(f, -1)	-1	9	rc=-1 errno=9 equals_target=1
CASE	4.7	_dup2 dup2(f, 1000000)	-1	9	rc=-1 errno=9 equals_target=0
CASE	4.8	_dup2 dup2(f, 0x7fffffff)	-1	9	rc=-1 errno=9 equals_target=0
CASE	5.1	dup(f) shares the file offset	0	0	offset_f_equals_g=1 offset_is_1=1
CASE	5.2	close-on-exec flag of f and of dup(f)	0	0	f_flag=1 dup_flag=0
CASE	5.3	dup2(f, 51) with the flag set on f	51	0	rc=51 flag_of_target=0
CASE	5.4	fcntl(f, F_DUPFD_CLOEXEC, 52)	-1	0	rc_ge_52=0 flag_of_result=-1 errno=45
CASE	5.5	write through the duplicate after the original is closed	1	0	write_rc=1
CASE	6.1	open(f1) in a loop up to 4096 descriptors or 5 seconds	632	24	opened=632 errno_at_stop=24 stopped_by_failure=1 stopped_by_limit_4096=0 stopped_by_time=0 getdtablesize=12555
CASE	6.2	dup(f) at the full limit	640	0	rc=640 errno=0
CASE	6.3	close every descriptor opened by the loop	0	0	closed=632 of 632
CASE	9	cleanup: close and remove f1 and the directory	0	0	unlink_f1=0 rmdir_dir=0
END	31

AI-assisted (Claude Code).

@github-actions github-actions Bot added the docs label Nov 18, 2026
@oneandonlydean
oneandonlydean merged commit e0d7df1 into boykopovar:main Nov 18, 2026
12 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants