in reply to Re^2: "readdir() attempted on invalid dirhandle" error?
in thread "readdir() attempted on invalid dirhandle" error?

From chdir function ...
... chdir FILEHANDLE chdir DIRHANDLE ... On systems that support fchdir(2), you may pass a filehandle or dire +ctory handle as the argument. On systems that don't support fchdir(2) +, passing handles raises an exception.

... fchdir(2) ought to be present on POSIX-conforming systems, from "fchdir(2)" manual page of FreeBSD 14 ...

... STANDARDS The chdir() system call is expected to conform to IEEE Std 1003.1 +-1990 (“POSIX.1”). HISTORY The chdir() system call appeared in Version 1 AT&T UNIX. The fchdir( +) system call appeared in 4.2BSD.