* Re: [PATCH v2 1/4] posix_spawn.3: Document implementation using clone() since glibc 2.24
[not found] ` <20181016193751.4473-2-olivier.gayot@sigexec.com>
@ 2020-04-17 10:35 ` Michael Kerrisk (man-pages)
[not found] ` <87d0s5hsfs.fsf@mid.deneb.enyo.de>
1 sibling, 0 replies; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-04-17 10:35 UTC (permalink / raw)
To: Olivier Gayot; +Cc: mtk.manpages, linux-man, Adhemerval Zanella
Hello Olivier
On 10/16/18 9:37 PM, Olivier Gayot wrote:
> Since glibc 2.24, the use of posix_spawn (2) makes an unconditional call
> to clone(CLONE_VM | CLONE_VFORK ...) rather than relying on fork (2) or
> vfork (2).
>
> As a consequence, the statements regarding the use of the flag
> POSIX_SPAWN_USEVFORK and how the function decides whether it should use
> fork (2) or vfork (2) are obsolete since glibc 2.24.
>
> This patch makes a distinction in the manual page between glibc 2.24 and
> older versions.
>
> Upstream commit in glibc.git:
>
> 9ff72da471 posix: New Linux posix_spawn{p} implementation
>
> Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
My apologies for the delay. This patch is now applied. Thanks for
sending it.
Adhemerval, thank you for your reviews.
Cheers,
Michael
> ---
> man3/posix_spawn.3 | 26 ++++++++++++++++++--------
> 1 file changed, 18 insertions(+), 8 deletions(-)
>
> diff --git a/man3/posix_spawn.3 b/man3/posix_spawn.3
> index 3e1e9011c..e8c0de172 100644
> --- a/man3/posix_spawn.3
> +++ b/man3/posix_spawn.3
> @@ -155,9 +155,16 @@ and the
> .BR exec ()
> step (executed in the child).
> .SS fork() step
> -The
> +Since glibc 2.24, the
> .BR posix_spawn ()
> function commences by calling
> +.BR clone (2)
> +with
> +.BR CLONE_VM
> +and
> +.BR CLONE_VFORK
> +flags.
> +Older implementations use
> .BR fork (2),
> or possibly
> .BR vfork (2)
> @@ -176,7 +183,7 @@ If the child fails in any of the housekeeping steps described below,
> or fails to execute the desired file,
> it exits with a status of 127.
> .PP
> -The child process is created using
> +Before glibc 2.24, the child process is created using
> .BR vfork (2)
> instead of
> .BR fork (2)
> @@ -480,14 +487,16 @@ The
> and
> .BR posix_spawnp ()
> functions fail only in the case where the underlying
> -.BR fork (2)
> -or
> +.BR fork (2),
> .BR vfork (2)
> +or
> +.BR clone (2)
> call fails; in these cases, these functions return an error number,
> which will be one of the errors described for
> -.BR fork (2)
> +.BR fork (2),
> +.BR vfork (2)
> or
> -.BR vfork (2).
> +.BR clone (2).
> .PP
> In addition, these functions fail if:
> .TP
> @@ -527,13 +536,14 @@ only the POSIX-specified functions.
> although these objects may be implemented as structures containing fields,
> portable programs must avoid dependence on such implementation details.)
> .PP
> -According to POSIX, it unspecified whether fork handlers established with
> +According to POSIX, it is unspecified whether fork handlers established with
> .BR pthread_atfork (3)
> are called when
> .BR posix_spawn ()
> is invoked.
> -On glibc,
> +Since glibc 2.24, the fork handlers are not executed in any case.
> .\" Tested on glibc 2.12
> +On older implementations,
> fork handlers are called only if the child is created using
> .BR fork (2).
> .PP
>
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 1/4] posix_spawn.3: Document implementation using clone() since glibc 2.24
[not found] ` <87d0s5hsfs.fsf@mid.deneb.enyo.de>
@ 2020-04-17 10:36 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-04-17 10:36 UTC (permalink / raw)
To: Florian Weimer, Olivier Gayot; +Cc: mtk.manpages, linux-man, Adhemerval Zanella
Florian,
On 10/20/18 11:35 AM, Florian Weimer wrote:
> * Olivier Gayot:
>
>> As a consequence, the statements regarding the use of the flag
>> POSIX_SPAWN_USEVFORK and how the function decides whether it should use
>> fork (2) or vfork (2) are obsolete since glibc 2.24.
>
> Maybe we should add that it is always never correct to use
> POSIX_SPAWN_USEVFORK?
>
> Either you are on a glibc which ignores it, then it is pointless, or
> on a glibc which has buggy semantics when vfork is used, so you
> probably do not want to use it.
Could you formulate a sentence for me that I could drop into
the current manual page?
Are there any bug reports about the older buggy semantics that I
can add as part of a commit message?
Thanks,
Michael
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 2/4] posix_spawn.3: Document POSIX_SPAWN_USEVFORK
[not found] ` <20181016193751.4473-3-olivier.gayot@sigexec.com>
@ 2020-04-17 10:45 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-04-17 10:45 UTC (permalink / raw)
To: Olivier Gayot; +Cc: mtk.manpages, linux-man, Adhemerval Zanella
Hello Olivier,
On 10/16/18 9:37 PM, Olivier Gayot wrote:
> Added a few lines about POSIX_SPAWN_USEVFORK so that it appears clearly
> that since glibc 2.24, the flag has no effect.
>
> Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Thanks. Patch applied.
Cheers,
Michael
> ---
> man3/posix_spawn.3 | 12 ++++++++++++
> 1 file changed, 12 insertions(+)
>
> diff --git a/man3/posix_spawn.3 b/man3/posix_spawn.3
> index e8c0de172..8badb43bf 100644
> --- a/man3/posix_spawn.3
> +++ b/man3/posix_spawn.3
> @@ -382,6 +382,18 @@ the child's process group ID is made the same as its process ID.
> If the
> .B POSIX_SPAWN_SETPGROUP
> flag is not set, the child inherits the parent's process group ID.
> +.TP
> +.B POSIX_SPAWN_USEVFORK
> +Since glibc 2.24, this flag has no effect.
> +On older implementations, setting this flag forces the
> +.BR fork()
> +step to use
> +.BR vfork (2)
> +instead of
> +.BR fork (2).
> +The
> +.B _GNU_SOURCE
> +feature test macro must be defined to obtain the definition of this contant.
> .PP
> If
> .I attrp
>
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 3/4] posix_spawn.3: Clarify by using name of steps rather than syscalls
[not found] ` <20181016193751.4473-4-olivier.gayot@sigexec.com>
@ 2020-04-17 10:45 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-04-17 10:45 UTC (permalink / raw)
To: Olivier Gayot; +Cc: mtk.manpages, linux-man, Adhemerval Zanella
Hello Olivier,
On 10/16/18 9:37 PM, Olivier Gayot wrote:
> The implementation of the fork() step in posix_spawn(2) relies on either
> fork(2), vfork(2) or clone(2) depending on the version of the
> glibc and the arguments passed to posix_spawn(2).
>
> It is sometimes ambiguous whether, when we are mentioning "fork(2)", we
> are referring to the fork() step or the actual fork(2) syscall.
>
> This patch hopefully avoids the ambiguity by replacing confusing
> occurrences by "the xxx() step" where appropriate.
>
> Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
Thanks. Patch applied.
Cheers,
Michael
> ---
> man3/posix_spawn.3 | 10 +++++-----
> 1 file changed, 5 insertions(+), 5 deletions(-)
>
> diff --git a/man3/posix_spawn.3 b/man3/posix_spawn.3
> index 8badb43bf..72e7509d8 100644
> --- a/man3/posix_spawn.3
> +++ b/man3/posix_spawn.3
> @@ -220,10 +220,10 @@ the requested file.
> .PP
> .SS pre-exec() step: housekeeping
> In between the
> -.BR fork (2)
> +.BR fork()
> and the
> -.BR exec (3),
> -a child process may need to perform a set of housekeeping actions.
> +.BR exec()
> +steps, a child process may need to perform a set of housekeeping actions.
> The
> .BR posix_spawn ()
> and
> @@ -478,8 +478,8 @@ and
> place the PID of the child process in
> .IR pid ,
> and return 0.
> -If there is an error before or during the
> -.BR fork (2),
> +If there is an error during the
> +.BR fork() step,
> then no child is created,
> the contents of
> .IR *pid
>
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH v2 4/4] posix_spawn.3: Document the POSIX_SPAWN_SETSID attribute
[not found] ` <20181016193751.4473-5-olivier.gayot@sigexec.com>
@ 2020-04-17 10:46 ` Michael Kerrisk (man-pages)
0 siblings, 0 replies; 5+ messages in thread
From: Michael Kerrisk (man-pages) @ 2020-04-17 10:46 UTC (permalink / raw)
To: Olivier Gayot; +Cc: mtk.manpages, linux-man, Adhemerval Zanella
Hello Olivier,
On 10/16/18 9:37 PM, Olivier Gayot wrote:
> Since glibc 2.26, posix_spawn (2) function accepts the
> POSIX_SPAWN_SETSID flag. This flag has been accepted by POSIX and should
> be added to the next major revision. The current support can be enabled
> with _GNU_SOURCE.
>
> Upstream commit in glibc.git:
>
> daeb1fa2e1 [BZ 21340] add support for POSIX_SPAWN_SETSID
Thanks. Patch applied.
Cheers,
Michael
> Signed-off-by: Olivier Gayot <olivier.gayot@sigexec.com>
> ---
> man3/posix_spawn.3 | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/man3/posix_spawn.3 b/man3/posix_spawn.3
> index 72e7509d8..93f1124a1 100644
> --- a/man3/posix_spawn.3
> +++ b/man3/posix_spawn.3
> @@ -394,6 +394,20 @@ instead of
> The
> .B _GNU_SOURCE
> feature test macro must be defined to obtain the definition of this contant.
> +.TP
> +.BR POSIX_SPAWN_SETSID " (since glibc 2.26)"
> +If this flag is set,
> +the child process shall create a new session and become the session leader.
> +The child process shall also become the process group leader of the new process
> +group in the session (see
> +.BR setsid (2)).
> +The
> +.B _GNU_SOURCE
> +feature test macro must be defined to obtain the definition of this contant.
> +.\" This flag has been accepted in POSIX, see:
> +.\" http://austingroupbugs.net/view.php?id=1044
> +.\" and has been implemented in glibc since version 2.26
> +.\" commit daeb1fa2e1b33323e719015f5f546988bd4cc73b
> .PP
> If
> .I attrp
--
Michael Kerrisk
Linux man-pages maintainer; http://www.kernel.org/doc/man-pages/
Linux/UNIX System Programming Training: http://man7.org/training/
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2020-04-17 10:46 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20181016193751.4473-1-olivier.gayot@sigexec.com>
[not found] ` <20181016193751.4473-2-olivier.gayot@sigexec.com>
2020-04-17 10:35 ` [PATCH v2 1/4] posix_spawn.3: Document implementation using clone() since glibc 2.24 Michael Kerrisk (man-pages)
[not found] ` <87d0s5hsfs.fsf@mid.deneb.enyo.de>
2020-04-17 10:36 ` Michael Kerrisk (man-pages)
[not found] ` <20181016193751.4473-3-olivier.gayot@sigexec.com>
2020-04-17 10:45 ` [PATCH v2 2/4] posix_spawn.3: Document POSIX_SPAWN_USEVFORK Michael Kerrisk (man-pages)
[not found] ` <20181016193751.4473-4-olivier.gayot@sigexec.com>
2020-04-17 10:45 ` [PATCH v2 3/4] posix_spawn.3: Clarify by using name of steps rather than syscalls Michael Kerrisk (man-pages)
[not found] ` <20181016193751.4473-5-olivier.gayot@sigexec.com>
2020-04-17 10:46 ` [PATCH v2 4/4] posix_spawn.3: Document the POSIX_SPAWN_SETSID attribute Michael Kerrisk (man-pages)
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).