-
Notifications
You must be signed in to change notification settings - Fork 197
Reflect application changes to argv[0] in /proc/self/cmdline #5070
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: main
Are you sure you want to change the base?
Conversation
|
Oh wow, I completely missed that would have been a possible work around. Good job! |
|
I wouldn't have known this was possible without your comment :) I see one test is failing, but it looks unrelated to my change. Could this be a test issue? |
|
That's definitely a spooky spurious failure. |
| const auto& Args = GetApplicationArguments(); | ||
| const char NullChar {}; | ||
| // cmdline is an array of null terminated arguments | ||
| for (const auto& Arg : Args) { | ||
| write(fd, Arg.c_str(), Arg.size()); | ||
| write(fd, &NullChar, sizeof(uint8_t)); | ||
| } |
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.
fextl::string is null-terminated:
| const auto& Args = GetApplicationArguments(); | |
| const char NullChar {}; | |
| // cmdline is an array of null terminated arguments | |
| for (const auto& Arg : Args) { | |
| write(fd, Arg.c_str(), Arg.size()); | |
| write(fd, &NullChar, sizeof(uint8_t)); | |
| } | |
| const auto& Args = GetApplicationArguments(); | |
| // cmdline is an array of null terminated arguments | |
| for (const auto& Arg : Args) { | |
| write(fd, Arg.c_str(), Arg.size() + 1); | |
| } |
Btw is this implementation used anywhere in practice or do we only ever call the override from ELFCodeLoader.h?
| } | ||
|
|
||
| void WriteCmdlineFD(int32_t fd) const override { | ||
| write(fd, reinterpret_cast<const void*>(StackPointer + ArgumentOffset), ArgumentBackingSize); |
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 line probably merits an explanatory comment.
Have you tried using the |
This is a simple fix for issue #5069, adjusting
/proc/self/cmdlineemulation for ELFCodeLoader to output the contents of the stack's argv data rather than the stashed argument strings. This means application writes to argv[0] will be visible to in-process/proc/self/cmdlinereads. The change is still not visible to external processes.I've tested that the rename_process.c script attached to the issue now works the same in and out of FEX: