Fix env not gathered and not passed to child processes

This commit is contained in:
Krzosa Karol
2026-02-07 14:28:16 +01:00
parent 17f4306fc3
commit 84fa04e1db
3 changed files with 23 additions and 6 deletions

View File

@@ -250,8 +250,10 @@ Process SpawnProcess(ExecArgs args) {
char *exe = Copy(scratch, args.exe).data;
For (args.env) {
Add(&env, Copy(scratch, it).data);
Add(&env, it.data);
}
Add(&env, (char *)"\0");
int stdout_desc[2] = {};
int stdin_desc[2] = {};
@@ -403,7 +405,7 @@ void CloseStdin(Process *process) {
}
#else
Process SpawnProcess(String command_line, String working_dir, String write_stdin, Array<String> enviroment) { return {}; }
Process SpawnProcess(ExecArgs args) { return {}; }
bool IsValid(Process *process) { return false; }
void KillProcess(Process *process) { }
String PollStdout(Allocator allocator, Process *process, bool force_read) { return {}; }

View File

@@ -1,4 +1,6 @@
/*
- [ ] BRO, the caret teleports on linux when I press the arrow for too long
- [ ] Cleanups
- [ ] How to enable framerate to be unlimited and not break scrolling?
- [x] When dragging a file into the editor, would be nice if the file opened in the window user dropped the file into. Not the active window.
@@ -10,6 +12,10 @@
- [ ] Directory tree doesn't make much sense! Maybe just consolidate into one folder? create nice names - the raddbg idea didn't pan out well here
- [ ] Test BlockArena correctnsess - random allocations, writes and undos, try to crash
- [ ] General parser / data description thing
- [ ] Rewrite other parsers using this
- [ ] Rewrite Env handling (to not be OS specific)
- New error mechanism - we were losing errors when ReportError was called multiple times, I still want that but I don't want to lose errors, so turn it into a summary list of errors
- [ ] BeginLog EndLog, and then show all logs as a list in the UI thing
- [ ] Undo kinds (to enable history in fuzzy buffers)
@@ -887,7 +893,7 @@ void MainLoop() {
int WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nShowCmd)
#else
extern char **environ;
int main(int argc, char **argv)
int main(int argc, char **argv, char **envp)
#endif
{
#if OS_WINDOWS
@@ -924,8 +930,16 @@ int main(int argc, char **argv)
// FreeEnvironmentStringsW(p); // I get a trap here? why?
}
#else
for (int i = 0; environ[i]; i += 1) {
Add(&ProcessEnviroment, Copy(Perm, environ[i]));
char **env = envp;
if (!env || !env[0]) {
env = environ;
}
if (env && env[0]) {
for (int i = 0; env[i]; i += 1) {
Add(&ProcessEnviroment, Copy(Perm, env[i]));
}
} else {
ReportErrorf("No environment variables found (envp/environ empty)");
}
#endif

View File

@@ -530,6 +530,7 @@ BSet Open(Window *window, String path, ResolveOpenMeta meta, bool set_active = t
CenterView(window->id);
} else if (o.kind == OpenKind_Exec) {
ExecArgs args = {};// ShellArgs(scratch, LogView->id, o.path, GetPrimaryDirectory());
args.env = ProcessEnviroment;
args.poll_process = 1;
args.output_view = LogView->id;
args.cwd = GetPrimaryDirectory();