Skip to content

reexec: touch-up docs and add some example uses#206

Merged
thaJeztah merged 1 commit intomoby:mainfrom
thaJeztah:reexec_docs
Apr 17, 2026
Merged

reexec: touch-up docs and add some example uses#206
thaJeztah merged 1 commit intomoby:mainfrom
thaJeztah:reexec_docs

Conversation

@thaJeztah
Copy link
Copy Markdown
Member

No description provided.

@thaJeztah thaJeztah force-pushed the reexec_docs branch 3 times, most recently from 3c28d03 to ed57227 Compare March 2, 2026 07:35
Comment thread reexec/reexec.go
// fork-without-exec in Go, since the runtime is not fork-safe once multiple
// threads exist (see [os.StartProcess] and https://go.dev/issue/27505).
//
// Example (multi-call binary):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

nit: I would move example to a separate file, example_test.go or so. Having example in comments means that it is never even compiled, which will make it outdated.

Go examples are at least compiled.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah; I did that for the other one; but was looking for a "here's how it would be used for multi-call binary", and of course the symlinks aren't really something to do in an example test.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

and of course the symlinks aren't really something to do in an example test.

I think it can still be done, you just create the binary first using go test -c and then go create symlinks. I haven't tested this, but in case your example has // Output: line at the end of the function, it will actually be run during tests (to check the output matches).

I agree it can be cumbersome though, so if you want it to leave as it, I'm fine with it.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Yeah, it's possible to test probably, but I don't think that works for pkg.go.dev to do something similar to that 🤔

I think this one is fine to keep; I'm adding a second "mocked" example for this scenario in #208

@thaJeztah thaJeztah requested a review from kolyshkin March 3, 2026 10:54
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@thaJeztah thaJeztah merged commit 7f6a0a1 into moby:main Apr 17, 2026
20 checks passed
@thaJeztah thaJeztah deleted the reexec_docs branch April 17, 2026 14:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants