On Mon, 2025-02-03 at 16:56 +0100, Alejandro Colomar wrote: > Hi Chen, > > On Mon, Feb 03, 2025 at 11:30:05PM +0800, Chen Linxuan wrote: > > --- > > man/man2/clone.2 | 13 ++++++++++++- > > 1 file changed, 12 insertions(+), 1 deletion(-) > > > > diff --git a/man/man2/clone.2 b/man/man2/clone.2 > > index 3ffe8e7b8..cd63fe0b1 100644 > > --- a/man/man2/clone.2 > > +++ b/man/man2/clone.2 > > @@ -1891,6 +1891,7 @@ main(int argc, char *argv[]) > > char *stackTop; /* End of stack buffer */ > > pid_t pid; > > struct utsname uts; > > + int savedErrno; > > \& > > if (argc < 2) { > > fprintf(stderr, "Usage: %s <child\-hostname>\[rs]n", argv[0]); > > @@ -1910,8 +1911,18 @@ main(int argc, char *argv[]) > > child commences execution in childFunc(). */ > > \& > > pid = clone(childFunc, stackTop, CLONE_NEWUTS | SIGCHLD, argv[1]); > > - if (pid == \-1) > > +\& > > + /* Free child stack, as it is not used by the parent. */ > > +\& > > + savedErrno = errno; > > + if (munmap(stack, STACK_SIZE)) { > > + warn("munmap"); > > + } > > + errno = savedErrno; > > +\& > > + if (pid == \-1) { > > err(EXIT_FAILURE, "clone"); > > + } > > This is too complex for an example program. A goto alternative might be > easier. I am agree, but I couldn't figure out a simple way to implement this. Do you have any suggestion? > > > Cheers, > Alex > > > printf("clone() returned %jd\[rs]n", (intmax_t) pid); > > \& > > /* Parent falls through to here */ > > -- > > 2.43.0 > > >