TL;DR
calling (open-source-file sfd) with sfd containing a path to a non-seekable device, fails and returns #f.
Internally it opens a file descriptor that is never closed nor associated to a returned port - i.e. it is leaked.
How to reproduce:
$ scheme
Chez Scheme Version 10.3.0
Copyright 1984-2025 Cisco Systems, Inc.
> (define sfd (make-source-file-descriptor "/dev/tty" (open-bytevector-input-port #vu8())))
On Linux, executing ls -l /proc/CHEZ_SCHEME_PID/fd from another terminal shows:
total 0
lrwx------ 1 max users 64 Apr 6 14:23 0 -> /dev/pts/0
lrwx------ 1 max users 64 Apr 6 14:23 1 -> /dev/pts/0
lrwx------ 1 max users 64 Apr 6 14:23 2 -> /dev/pts/0
Now run the following in Chez Scheme:
> (open-source-file sfd)
#f
Note: (open-source-file sfd) fails and returns #f because /dev/tty is not seekable. One expects that any resource internally allocated by (open-source-file sfd) is released in case of failure.
Execute again ls -l /proc/CHEZ_SCHEME_PID/fd from another terminal. The output is:
total 0
lrwx------ 1 max users 64 Apr 6 14:23 0 -> /dev/pts/0
lrwx------ 1 max users 64 Apr 6 14:23 1 -> /dev/pts/0
lrwx------ 1 max users 64 Apr 6 14:23 2 -> /dev/pts/0
lr-x------ 1 max users 64 Apr 6 14:24 3 -> /dev/tty
i.e. file descriptor for /dev/tty is still open, but not associated to a port or some similar resource: it has been leaked.
TL;DR
calling
(open-source-file sfd)withsfdcontaining a path to a non-seekable device, fails and returns#f.Internally it opens a file descriptor that is never closed nor associated to a returned port - i.e. it is leaked.
How to reproduce:
On Linux, executing
ls -l /proc/CHEZ_SCHEME_PID/fdfrom another terminal shows:Now run the following in Chez Scheme:
Note:
(open-source-file sfd)fails and returns#fbecause/dev/ttyis not seekable. One expects that any resource internally allocated by(open-source-file sfd)is released in case of failure.Execute again
ls -l /proc/CHEZ_SCHEME_PID/fdfrom another terminal. The output is:i.e. file descriptor for
/dev/ttyis still open, but not associated to a port or some similar resource: it has been leaked.