- Notifications
You must be signed in to change notification settings - Fork1k
os,runtime: make sure executable path is fully resolved at process init#4881
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
base:dev
Are you sure you want to change the base?
Uh oh!
There was an error while loading.Please reload this page.
Conversation
dgryski commentedMay 1, 2025
Not sure I like this solution; it pulls in a bunch of code from syscall to get the cwd at process init. |
aykevl left a comment• edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
This seems like a reasonable solution, even if not perfect (I can't think of a better way right now). Some nits below.
| varexecutablePathstring | ||
| funcplatform_argv(argcint32,argv*unsafe.Pointer) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Hmm, I'm not sure I like this name. What aboutstoreExecutablePath or something like that?
| constpathMax=1024 | ||
| varbuf [4*pathMax]byte |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
Why use 1024 and then use 4 times that size in the actual buffer? (Also, it would help to give a pointer to why that is the right value, like a link to a man page or something).
| ifn<1 { | ||
| return"" | ||
| } | ||
| returnstring(buf[:n]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others.Learn more.
You could consider usingunsafe.String here to avoid an allocation. It should be safe, sincebuf is never modified afterwards. (The potential downside is thatexecutablePath will then always be 4kB in size - not sure whether that's a good tradeoff).
No description provided.