-
Notifications
You must be signed in to change notification settings - Fork 994
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 our terms of service and privacy 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?
os,runtime: make sure executable path is fully resolved at process init #4881
Conversation
|
Not sure I like this solution; it pulls in a bunch of code from syscall to get the cwd at process init. |
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.
|
|
||
| var executablePath string | ||
|
|
||
| func platform_argv(argc int32, 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 about storeExecutablePath or something like that?
| const pathMax = 1024 | ||
| var buf [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).
| if n < 1 { | ||
| return "" | ||
| } | ||
| return string(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 using unsafe.String here to avoid an allocation. It should be safe, since buf is never modified afterwards. (The potential downside is that executablePath will then always be 4kB in size - not sure whether that's a good tradeoff).
No description provided.