-
Notifications
You must be signed in to change notification settings - Fork 238
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
feat(process): allow commands and envs on proces_start #1477
feat(process): allow commands and envs on proces_start #1477
Conversation
Currently, supplying any commands more than 156 causes stack corruption due to Lua freeing the pointer to the string. |
Refactors the code to use an arglist type which is just lpCmdline on Windows and a list in Linux. The function automatically escapes the command when it is needed, avoiding a second copy. This also allows UTF-8 commands btw.
With the latest commit, the parent's environment variables are passed to the child process |
Will test this on windows in the near future, but otherwise, even if it's a bit longer/larger than I would hope for, looks good. |
On windows, running the following code causes an issue:
It didn't before; runs fine on the original code. |
I cannot replicate this issue; but I believe I found the cause and committed a fix. Please test it. |
Yes, this now runs. Confirmed. Will do some more testing, and if it all looks good, will merge. |
OK, reviewed code a bit more; bit weird about the allocations being very different on Windows vs. everywhere else, but Windows is windows, and I seem to remember something about needing contiguous blocks or whatever; so I'm sure that's fine. Merging. |
Yeah, Windows environment block expects a long "string" of each environment variables delimited by NUL. |
* feat(process): allow commands and envs on proces_start * refactor(process): copy process arguments once whenever possible Refactors the code to use an arglist type which is just lpCmdline on Windows and a list in Linux. The function automatically escapes the command when it is needed, avoiding a second copy. This also allows UTF-8 commands btw. * fix(process): fix invalid dereference * refactor(process): mark xstrdup as potentially unused * feat(process): add parent process environment when launching process * fix(process): fix operator precedence with array operators * fix(process): fix segfault when freeing random memory * fix(process): fix wrong check for setenv() * fix(process): fix accidentally initializing an array by assignment * fix(process): clear return value if success
This would allow something like this:
To run correctly.