clone.2, sigaltstack.2: clone(CLONE_VM) disdables the alternate signal stack

In the kernel sources (kernel/fork.c::copy_process()), we have:

        /*
         * sigaltstack should be cleared when sharing the same VM
         */
        if ((clone_flags & (CLONE_VM|CLONE_VFORK)) == CLONE_VM)
                sas_ss_reset(p);

Signed-off-by: Michael Kerrisk <mtk.manpages@gmail.com>
This commit is contained in:
Michael Kerrisk 2020-11-12 14:07:17 +01:00
parent 1374ba4278
commit 52e5819c41
2 changed files with 17 additions and 0 deletions

View File

@ -1181,6 +1181,15 @@ space of the calling process at the time of the clone call.
Memory writes or file mappings/unmappings performed by one of the
processes do not affect the other, as with
.BR fork (2).
.IP
If the
.BR CLONE_VM
flag is specified and the
.BR CLONE_VM
flag is not specified,
then any alternate signal stack that was established by
.BR sigaltstack (2)
is cleared in the child process.
.SH RETURN VALUE
.\" gettid(2) returns current->pid;
.\" getpid(2) returns current->tgid;

View File

@ -269,6 +269,14 @@ signal stack.
A child process created via
.BR fork (2)
inherits a copy of its parent's alternate signal stack settings.
The same is also true for a child process created using
.BR clone (2),
unless the clone flags include
.BR CLONE_VM
and do not include
.BR CLONE_VFORK ,
in which case any alternate signal stack that was established in the parent
is disabled in the child process.
.PP
.BR sigaltstack ()
supersedes the older