mailing list of musl libc
 help / color / mirror / code / Atom feed
* Re: posix_spawn_file_actions_add* functions on musl libc
       [not found] <17480807.kbxdrRNLtY@omega>
@ 2019-03-24 14:16 ` Rich Felker
  2019-03-24 18:23   ` Bruno Haible
  0 siblings, 1 reply; 3+ messages in thread
From: Rich Felker @ 2019-03-24 14:16 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib, musl

On Sat, Mar 23, 2019 at 09:46:28PM +0100, Bruno Haible wrote:
> The gnulib configure test in m4/posix_spawn.m4, when run on Alpine Linux 3.7,
> determines that the posix_spawn_file_actions_add* functions do not fail as
> expected for an out-of-range file descriptor.

The POSIX "shall fail" requirement is for >=OPEN_MAX, which is not
defined (variable limit). It's not clear to me whether it's supposed
to apply if the fd number is >= the current dynamic limit reported by
sysconf(_SC_OPEN_MAX), but it seems like doing so would be undesirable
-- it would preclude advance creation of a file actions object which
will open or dup onto high fd numbers at a later time after the rlimit
has been increased.

Rich


> Let me document this in gnulib and update the cross-compilation guess
> accordingly.
> 
> Rich, FYI: These are the test programs:
> 
> #include <spawn.h>
> int main ()
> {
>   posix_spawn_file_actions_t actions;
>   if (posix_spawn_file_actions_init (&actions) != 0)
>     return 1;
>   if (posix_spawn_file_actions_addclose (&actions, 10000000) == 0)
>     return 2;
>   return 0;
> }
> 
> #include <spawn.h>
> int main ()
> {
>   posix_spawn_file_actions_t actions;
>   if (posix_spawn_file_actions_init (&actions) != 0)
>     return 1;
>   if (posix_spawn_file_actions_adddup2 (&actions, 10000000, 2) == 0)
>     return 2;
>   return 0;
> }
> 
> #include <spawn.h>
> #include <fcntl.h>
> int main ()
> {
>   posix_spawn_file_actions_t actions;
>   if (posix_spawn_file_actions_init (&actions) != 0)
>     return 1;
>   if (posix_spawn_file_actions_addopen (&actions, 10000000, "foo", 0, O_RDONLY)
>       == 0)
>     return 2;
>   return 0;
> }
> 
> 
> 2019-03-23  Bruno Haible  <bruno@clisp.org>
> 
> 	posix_spawn_file_actions_*: Document musl libc bugs.
> 	* doc/posix-functions/posix_spawn_file_actions_addclose.texi: Mention
> 	the bug.
> 	* doc/posix-functions/posix_spawn_file_actions_adddup2.texi: Likewise.
> 	* doc/posix-functions/posix_spawn_file_actions_addopen.texi: Likewise.
> 	* m4/posix_spawn.m4 (gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE): When
> 	cross-compiling to a musl system, guess no.
> 	(gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2): Likewise.
> 	(gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN): Likewise.
> 
> diff --git a/doc/posix-functions/posix_spawn_file_actions_addclose.texi b/doc/posix-functions/posix_spawn_file_actions_addclose.texi
> index 199daa1..80418db 100644
> --- a/doc/posix-functions/posix_spawn_file_actions_addclose.texi
> +++ b/doc/posix-functions/posix_spawn_file_actions_addclose.texi
> @@ -13,7 +13,7 @@ This function is missing on some platforms:
>  Mac OS X 10.4, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 8.1.
>  @item
>  This function does not reject a too large file descriptor on some platforms:
> -Solaris 11.4.
> +musl libc, Solaris 11.4.
>  @end itemize
>  
>  Portability problems not fixed by Gnulib:
> diff --git a/doc/posix-functions/posix_spawn_file_actions_adddup2.texi b/doc/posix-functions/posix_spawn_file_actions_adddup2.texi
> index e515715..985d6bc 100644
> --- a/doc/posix-functions/posix_spawn_file_actions_adddup2.texi
> +++ b/doc/posix-functions/posix_spawn_file_actions_adddup2.texi
> @@ -13,7 +13,7 @@ This function is missing on some platforms:
>  Mac OS X 10.4, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 8.1.
>  @item
>  This function does not reject a too large file descriptor on some platforms:
> -Solaris 11.4.
> +musl libc, Solaris 11.4.
>  @end itemize
>  
>  Portability problems not fixed by Gnulib:
> diff --git a/doc/posix-functions/posix_spawn_file_actions_addopen.texi b/doc/posix-functions/posix_spawn_file_actions_addopen.texi
> index a7809cf..eea56e3 100644
> --- a/doc/posix-functions/posix_spawn_file_actions_addopen.texi
> +++ b/doc/posix-functions/posix_spawn_file_actions_addopen.texi
> @@ -13,7 +13,7 @@ This function is missing on some platforms:
>  Mac OS X 10.4, FreeBSD 6.0, NetBSD 5.0, OpenBSD 3.8, Minix 3.1.8, AIX 5.1, HP-UX 11, IRIX 6.5, OSF/1 5.1, Solaris 9, Cygwin, mingw, MSVC 14, Interix 3.5, BeOS, Android 8.1.
>  @item
>  This function does not reject a too large file descriptor on some platforms:
> -Solaris 11.4.
> +musl libc, Solaris 11.4.
>  @end itemize
>  
>  Portability problems not fixed by Gnulib:
> diff --git a/m4/posix_spawn.m4 b/m4/posix_spawn.m4
> index 1e2533c..d50dcc9 100644
> --- a/m4/posix_spawn.m4
> +++ b/m4/posix_spawn.m4
> @@ -1,4 +1,4 @@
> -# posix_spawn.m4 serial 15
> +# posix_spawn.m4 serial 16
>  dnl Copyright (C) 2008-2019 Free Software Foundation, Inc.
>  dnl This file is free software; the Free Software Foundation
>  dnl gives unlimited permission to copy and/or distribute it,
> @@ -422,8 +422,8 @@ AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE],
>    if test $REPLACE_POSIX_SPAWN = 1; then
>      REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDCLOSE=1
>    else
> -    dnl On Solaris 11.0, posix_spawn_file_actions_addclose succeeds even
> -    dnl if the fd argument is out of range.
> +    dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_addclose
> +    dnl succeeds even if the fd argument is out of range.
>      AC_CACHE_CHECK([whether posix_spawn_file_actions_addclose works],
>        [gl_cv_func_posix_spawn_file_actions_addclose_works],
>        [AC_RUN_IFELSE(
> @@ -440,8 +440,9 @@ int main ()
>  }]])],
>           [gl_cv_func_posix_spawn_file_actions_addclose_works=yes],
>           [gl_cv_func_posix_spawn_file_actions_addclose_works=no],
> -         [# Guess no on Solaris, yes otherwise.
> +         [# Guess no on musl libc and Solaris, yes otherwise.
>            case "$host_os" in
> +            *-musl*)  gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;;
>              solaris*) gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;;
>                        # Guess no on native Windows.
>              mingw*)   gl_cv_func_posix_spawn_file_actions_addclose_works="guessing no" ;;
> @@ -465,8 +466,8 @@ AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2],
>    if test $REPLACE_POSIX_SPAWN = 1; then
>      REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDDUP2=1
>    else
> -    dnl On Solaris 11.0, posix_spawn_file_actions_adddup2 succeeds even
> -    dnl if the fd argument is out of range.
> +    dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_adddup2
> +    dnl succeeds even if the fd argument is out of range.
>      AC_CACHE_CHECK([whether posix_spawn_file_actions_adddup2 works],
>        [gl_cv_func_posix_spawn_file_actions_adddup2_works],
>        [AC_RUN_IFELSE(
> @@ -483,8 +484,9 @@ int main ()
>  }]])],
>           [gl_cv_func_posix_spawn_file_actions_adddup2_works=yes],
>           [gl_cv_func_posix_spawn_file_actions_adddup2_works=no],
> -         [# Guess no on Solaris, yes otherwise.
> +         [# Guess no on musl libc and Solaris, yes otherwise.
>            case "$host_os" in
> +            *-musl*)  gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no";;
>              solaris*) gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no";;
>                        # Guess no on native Windows.
>              mingw*)   gl_cv_func_posix_spawn_file_actions_adddup2_works="guessing no" ;;
> @@ -508,8 +510,8 @@ AC_DEFUN([gl_FUNC_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN],
>    if test $REPLACE_POSIX_SPAWN = 1; then
>      REPLACE_POSIX_SPAWN_FILE_ACTIONS_ADDOPEN=1
>    else
> -    dnl On Solaris 11.0, posix_spawn_file_actions_addopen succeeds even
> -    dnl if the fd argument is out of range.
> +    dnl On musl libc and Solaris 11.0, posix_spawn_file_actions_addopen
> +    dnl succeeds even if the fd argument is out of range.
>      AC_CACHE_CHECK([whether posix_spawn_file_actions_addopen works],
>        [gl_cv_func_posix_spawn_file_actions_addopen_works],
>        [AC_RUN_IFELSE(
> @@ -528,8 +530,9 @@ int main ()
>  }]])],
>           [gl_cv_func_posix_spawn_file_actions_addopen_works=yes],
>           [gl_cv_func_posix_spawn_file_actions_addopen_works=no],
> -         [# Guess no on Solaris, yes otherwise.
> +         [# Guess no on musl libc and Solaris, yes otherwise.
>            case "$host_os" in
> +            *-musl*)  gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no";;
>              solaris*) gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no";;
>                        # Guess no on native Windows.
>              mingw*)   gl_cv_func_posix_spawn_file_actions_addopen_works="guessing no" ;;


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: posix_spawn_file_actions_add* functions on musl libc
  2019-03-24 14:16 ` posix_spawn_file_actions_add* functions on musl libc Rich Felker
@ 2019-03-24 18:23   ` Bruno Haible
  2019-03-24 21:38     ` Rich Felker
  0 siblings, 1 reply; 3+ messages in thread
From: Bruno Haible @ 2019-03-24 18:23 UTC (permalink / raw)
  To: Rich Felker; +Cc: bug-gnulib, musl

Hi Rich,

> -- it would preclude advance creation of a file actions object which
> will open or dup onto high fd numbers at a later time after the rlimit
> has been increased.

This is a highly theoretical use-case, isn't it?

If you think POSIX should not specify things the way it does, please
report it to the Austin Group.

Bruno



^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: Re: posix_spawn_file_actions_add* functions on musl libc
  2019-03-24 18:23   ` Bruno Haible
@ 2019-03-24 21:38     ` Rich Felker
  0 siblings, 0 replies; 3+ messages in thread
From: Rich Felker @ 2019-03-24 21:38 UTC (permalink / raw)
  To: Bruno Haible; +Cc: bug-gnulib, musl

On Sun, Mar 24, 2019 at 07:23:16PM +0100, Bruno Haible wrote:
> Hi Rich,
> 
> > -- it would preclude advance creation of a file actions object which
> > will open or dup onto high fd numbers at a later time after the rlimit
> > has been increased.
> 
> This is a highly theoretical use-case, isn't it?
> 
> If you think POSIX should not specify things the way it does, please
> report it to the Austin Group.

If you read the rest of my email beyond the 2.5 lines quoted above, I
said it's not clear to me that POSIX requires what you think it does
in this case. If you disagree with that, we should open a request for
interpretation.

Rich


^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2019-03-24 21:38 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
     [not found] <17480807.kbxdrRNLtY@omega>
2019-03-24 14:16 ` posix_spawn_file_actions_add* functions on musl libc Rich Felker
2019-03-24 18:23   ` Bruno Haible
2019-03-24 21:38     ` Rich Felker

Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).