On Sat, 2021-03-06 at 17:55 +0100, Marius Bakke wrote:
> Hello Guilers,
> 
> [...]
> 
> It works great, except that the script filename (/tmp/test-shell) has
> an open file descriptor which leaks into the new process:
> 
> [...]
> 
> I've managed to work around it by setting FD_CLOEXEC on it:
> 
> [code using port-for-each and port-filename]
> 
> 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?

Easy way to access the ‘script port’: the Scheme procedure current-load-port.
Take a look at the output of the attached script.

Greetings,
Maxime
#!/gnu/store/m5iprcg6pb5ch86r9agmqwd8v6kp7999-guile-3.0.5/bin/guile --no-auto-compile
!#
(eval-when (expand)
  (pk 'expand (current-load-port) (fileno (current-load-port))))
(eval-when (load)
  (pk 'load (current-load-port) (fileno (current-load-port))))
(eval-when (eval)
  (pk 'eval (current-load-port) (fileno (current-load-port))))
(eval-when (compile)
  (pk 'compile (current-load-port) (fileno (current-load-port))))

Attachment: signature.asc
Description: This is a digitally signed message part

Reply via email to