On Sat 06 Mar 2021 17:55, Marius Bakke <mar...@gnu.org> writes:

> $ ls -l /proc/self/fd
> lrwx------ 1 marius marius 64 Mar  6 17:41 0 -> /dev/pts/18
> lrwx------ 1 marius marius 64 Mar  6 17:41 1 -> /dev/pts/18
> lrwx------ 1 marius marius 64 Mar  6 17:41 2 -> /dev/pts/18
> lr-x------ 1 marius marius 64 Mar  6 17:41 3 -> /proc/9940/fd
>
> $ /tmp/test-shell -c 'ls -l /proc/self/fd'
> lrwx------ 1 marius marius 64 Mar  6 17:41 0 -> /dev/pts/18
> lrwx------ 1 marius marius 64 Mar  6 17:41 1 -> /dev/pts/18
> lrwx------ 1 marius marius 64 Mar  6 17:41 2 -> /dev/pts/18
> lr-x------ 1 marius marius 64 Mar  6 17:41 3 -> /proc/9951/fd
> lr-x------ 1 marius marius 64 Mar  6 17:41 7 -> /tmp/test-shell
>
> I've managed to work around it by setting FD_CLOEXEC on it:
>
>   (port-for-each (lambda (port)
>                    (let ((name (port-filename port))
>                          (self (car (program-arguments))))
>                      (when (and name (string=? name self))
>                        (fcntl port F_SETFD (logior FD_CLOEXEC
>                                                    (fcntl port F_GETFD)))))))
>
> But it seems heavy-handed.  Is there an easier way to access the "script
> port"?  Perhaps Guile itself should make it FD_CLOEXEC by default?

I think Guile itself should make the load port FD_CLOEXEC / O_CLOEXEC.
More broadly there are a number of file descriptors in Guile that should
be cloexec but aren't yet.  Want to make a patch for the load port ? :)

Andy

Reply via email to