Edit

IABSD.fr/ports/lang/guile3/patches/patch-libguile_posix_c

Branch :

  • Show log

    Commit

  • Author : op
    Date : 2023-02-03 08:27:31
    Hash : f8042ea1
    Message : update lang/guile3 to 3.0.9 announce: https://www.gnu.org/software/guile/news/gnu-guile-309-released.html The new `spawn' and existing functions like `system*', `open-pipe' and `pipeline' are now implemented via posix_spawn, except that the way they run on non-linux OSes is wrong. The closing of _all_ file descriptors in the 3...RLIMIT_NOFILE is scheduled via posix_spawn_file_actions_addclose and, since not all the fds in that range are valid, close(2) fails and aborts posix_spawn. Add an ugly hack to close only in the 3...getdtablecount() range, testing each fd with fstat(2) to see if it's 'live'. Bug filed upstream, waiting for an official fix.

  • lang/guile3/patches/patch-libguile_posix_c
  • fix close_inherited_fds_slow
    
    The intent of close_inherited_fds_slow is to mimick closefrom() in the
    posix_spawn API, i.e. schedule the closing of all fds >= 3 after fork().
    
    However, the way this is implemented in non-linux OSes is to schedule
    the closing of 3..1023.  This fails due to EBADF in posix_spawn after
    the fork() and makes it exit(127).
    
    see: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=61095
    
    Index: libguile/posix.c
    --- libguile/posix.c.orig
    +++ libguile/posix.c
    @@ -1325,8 +1325,12 @@ SCM_DEFINE (scm_fork, "primitive-fork", 0, 0, 0,
     static void
     close_inherited_fds_slow (posix_spawn_file_actions_t *actions, int max_fd)
     {
    -  while (--max_fd > 2)
    -    posix_spawn_file_actions_addclose (actions, max_fd);
    +  struct stat sb;
    +  max_fd = getdtablecount();
    +  while (--max_fd > 2) {
    +    if (fstat(max_fd, &sb) != -1)
    +      posix_spawn_file_actions_addclose (actions, max_fd);
    +  }
     }
     
     static void