Skip to contentSkip to conversation

New: Man(3) system outdated

Bug 214871 [email protected] 1 participant 6 messages Oct 29, 2021 – Nov 2, 2021 Man-pages: manual pages for Linux -- Sections 2, 3, 4, 5, and 7

lore
Share & tools
lore
#0 lore raw

https://bugzilla.kernel.org/show_bug.cgi?id=214871

Bug ID: 214871
Summary: Man(3) system outdated
Product: Documentation
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: man-pages
Assignee: [email protected]
Reporter: [email protected]
Regression: No

During my recent university work, I have noticed the man (3) page for system
(https://man7.org/linux/man-pages/man3/system.3.html) states:

The system() library function uses fork(2) to create a child process that executes the shell command specified in command using execl(3) as follows:
execl("/bin/sh", "sh", "-c", command, (char *) NULL);

On reading the source code for system, this caused me some confusion. Eventually I found a commit from 2018
(https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=5fb7fc96350575c9adb1316833e48ca11553be49),
in which fork and exec were replaced by posix_spawn. The explains why I could not aline the man page with the source code.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#1 lore raw

[Bug 214871] Man(3) system outdated

https://bugzilla.kernel.org/show_bug.cgi?id=214871

--- Comment #1 from Alejandro Colomar (man-pages) ([email protected]) --- [CC += Glibc, Adhemerval]

Hi Adhemerval,

Quoted 23 lines · On 10/29/21 22:37, [email protected] wrote:

https://bugzilla.kernel.org/show_bug.cgi?id=214871

Bug ID: 214871
Summary: Man(3) system outdated
Product: Documentation
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: man-pages
Assignee: [email protected]
Reporter: [email protected]
Regression: No

During my recent university work, I have noticed the man (3) page for system
(https://man7.org/linux/man-pages/man3/system.3.html) states:

The system() library function uses fork(2) to create a child process that executes the shell command specified in command using execl(3) as follows:
execl("/bin/sh", "sh", "-c", command, (char *) NULL);

Quoted 7 lines

On reading the source code for system, this caused me some confusion. Eventually I found a commit from 2018

(https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=5fb7fc96350575c9adb1316833e48ca11553be49),
in which fork and exec were replaced by posix_spawn. The explains why I could not aline the man page with the source code.

I was about to change that line to say that it works "as if" using fork(2) and execl(3), as POSIX says, but then, reading the page further, it talks about many implementation details that seem to relate to when glibc did actually use fork(2). They may be outdated now, so I think it's better if someone from glibc that knows its current details reviews the full page and proposes changes.

Thanks,

Alex

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#2 lore raw

[Bug 214871] Man(3) system outdated

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=214871

--- Comment #2 from [email protected] ---

Quoted 41 lines · Alejandro Colomar (man-pages)

[CC += Glibc, Adhemerval]

Hi Adhemerval,

Quoted 16 lines · On 10/29/21 22:37, [email protected] wrote:

https://bugzilla.kernel.org/show_bug.cgi?id=214871

Bug ID: 214871
Summary: Man(3) system outdated
Product: Documentation
Version: unspecified
Hardware: All
OS: Linux
Status: NEW
Severity: normal
Priority: P1
Component: man-pages
Assignee: [email protected]
Reporter: [email protected]
Regression: No

Quoted 1 line

During my recent university work, I have noticed the man (3) page for

system

Quoted 4 lines

(https://man7.org/linux/man-pages/man3/system.3.html) states:

The system() library function uses fork(2) to create a child process that executes the shell command specified in command using execl(3) as

follows:

Quoted 5 lines

execl("/bin/sh", "sh", "-c", command, (char *) NULL);

On reading the source code for system, this caused me some confusion. Eventually I found a commit from 2018
(

https://sourceware.org/git/?p=glibc.git;a=commitdiff;h=5fb7fc96350575c9adb1316833e48ca11553be49
),

Quoted 1 line

in which fork and exec were replaced by posix_spawn. The explains why I

could

Quoted 2 lines

not aline the man page with the source code.

Quoted 7 lines

I was about to change that line to say that it works "as if" using fork(2) and execl(3), as POSIX says, but then, reading the page further, it talks about many implementation details that seem to relate to when glibc did actually use fork(2). They may be outdated now, so I think it's better if someone from glibc that knows its current details reviews the full page and proposes changes.

Hi Alejandro,

Indeed we changed glibc to use posix_spawn on system and popen on 2.29 since
to use posix_spawn (which uses clone (CLONE_VFORK | CLONE_VM)). It plays way better with Linux memory subsystem than fork() + exec() specially when such
calls are used with process with large RSS.

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#3 lore raw

[Bug 214871] Man(3) system outdated

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=214871

--- Comment #3 from Alejandro Colomar (man-pages) ([email protected]) --- Hi Adhemerval, Michael,

Quoted 8 lines · zatrazz

Hi Alejandro,

Indeed we changed glibc to use posix_spawn on system and popen on  2.29 since
to use posix_spawn (which uses clone (CLONE_VFORK | CLONE_VM)).  It plays way better with Linux memory subsystem than fork() + exec() specially when such
calls are used with process with large RSS.

I applied the following patch. I'll close the bug.

Thanks,

Alex

---
system.3: It doesn't call fork anymore

man3/system.3 +2 -2
index 880fe93c6..bde45ed82 100644
@@ -40,9 +40,9 @@ system \- execute a shell command
  .SH DESCRIPTION
  The
  .BR system ()
-library function uses
+library function behaves as if it used
  .BR fork (2)
-to create a child process that executes the shell command specified in
+to create a child process that executed the shell command specified in
  .I command
  using
  .BR execl (3)
Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#4 lore raw

[Bug 214871] Man(3) system outdated

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=214871

Alejandro Colomar (man-pages) ([email protected]) changed:

What |Removed |Added
----------------------------------------------------------------------------

             Status|NEW                         |RESOLVED
                 CC|                            |[email protected]
         Resolution|---                         |DOCUMENTED
Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.
#5 lore raw

[Bug 214871] Man(3) system outdated

In reply to [email protected]

https://bugzilla.kernel.org/show_bug.cgi?id=214871

--- Comment #4 from [email protected] ---

Quoted 12 lines · Alejandro Colomar (man-pages) via Libc-alpha

Hi Adhemerval, Michael,

Quoted 8 lines · zatrazz

Hi Alejandro,

Indeed we changed glibc to use posix_spawn on system and popen on  2.29 since
to use posix_spawn (which uses clone (CLONE_VFORK | CLONE_VM)).  It plays way better with Linux memory subsystem than fork() + exec() specially when such
calls are used with process with large RSS.

Quoted 5 lines

I applied the following patch.  I'll close the bug.

Thanks,

Alex

I forgot to add that neither system(), posix_spawn(), nor popen() call atfork handlers [1]. POSIX recently changed their description to make it implementation-defined instead of unspecified [2], so I think it is worth to change that is not really behave as called by fork() (since it will run atfork handlers).

[1] https://sourceware.org/bugzilla/show_bug.cgi?id=17490
[2] https://www.austingroupbugs.net/view.php?id=1317

Quoted 27 lines

---
    system.3: It doesn't call fork anymore

man3/system.3 +0 -0
index 880fe93c6..bde45ed82 100644
@@ -40,9 +40,9 @@ system \- execute a shell command

 .SH DESCRIPTION
 The
 .BR system ()

man3/system.3 +1 -1
-library function uses
+library function behaves as if it used

 .BR fork (2)

man3/system.3 +1 -1
-to create a child process that executes the shell command specified in
+to create a child process that executed the shell command specified in

 .I command
 using
 .BR execl (3)

Signature · 4 lines
You may reply to this email to add a comment.

You are receiving this mail because:
You are watching the assignee of the bug.