Skip to content

gh-125562: Update to documentation for exec* functions #125565

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 14 commits into
base: main
Choose a base branch
from

Conversation

jlownie
Copy link

@jlownie jlownie commented Oct 16, 2024

gh-125562: Update to documentation for exec* functions

This PR includes the following changes:

  • Moving the documentation of the first argument to the exec* functions from the start of the Process Management section to the documentation of the exec* functions.
  • Adding of headings within the exec* documentation.
  • Moving the final paragraph of the exec* functions documentation to the "Location of the executable", which is where it is logically relevant.
  • Adding links between the system(), execl and spawnl functions.
  • Adding links to the subprocess module.

📚 Documentation preview 📚: https://cpython-previews--125565.org.readthedocs.build/

@ghost
Copy link

ghost commented Oct 16, 2024

All commit authors signed the Contributor License Agreement.
CLA signed

Copy link
Member

@vadmium vadmium left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Putting the bracketed deprecation paragraphs at the top of each description is not great. Maybe move them down, if needed at all.

The various :func:`exec\* <execl>` functions take a list of arguments for the new
program loaded into the process. In each case, the first of these arguments must
be the name of the program itself, and not an argument that a user may
have typed on a command line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since you already edited the second sentence, I’ll point out that often the first word on a command line is indeed the program name (e.g. shell command “echo bar”) so saying “not an argument . . . typed on a command line” is confusing if not wrong.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm open to any suggestions as to better wording? That phrasing came from the original documentation, I agree it's not great but I found it difficult to come up with something better that I was confident was correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is my attempt:

The exec functions take a list of arguments for the new program. The first of these is by convention the command name from the command line, rather than an argument to the command, and becomes argv[0] passed to the main function of a C program. For example, os.execv('/bin/echo', ['echo', 'foo', 'bar']) would only print foo bar; the echo argument would seem to be ignored.

be the name of the program itself, and not an argument that a user may
have typed on a command line.

For the C programmer, this is the ``argv[0]``
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I’m not sure breaking the paragraph works. “This” refers to the name of the program (topic of the last sentence of the last paragraph), not the overall Program Arguments heading.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I decided to retain the paragraph break and instead reworded the first sentence in the paragraph. I'm not entirely sure what the documentation is getting at with the second sentence in the paragraph. I'm open to further suggestions for improving this paragraph - I feel it could be improved but I'm not sure how.

The various :func:`exec\* <execl>` functions take a list of arguments for the new
program loaded into the process. In each case, the first of these arguments must
be the name of the program itself, and not an argument that a user may
have typed on a command line.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here is my attempt:

The exec functions take a list of arguments for the new program. The first of these is by convention the command name from the command line, rather than an argument to the command, and becomes argv[0] passed to the main function of a C program. For example, os.execv('/bin/echo', ['echo', 'foo', 'bar']) would only print foo bar; the echo argument would seem to be ignored.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
awaiting review docs Documentation in the Doc dir skip news
Projects
Status: Todo
Development

Successfully merging this pull request may close these issues.

2 participants