Cleanup debug reporting situation

This commit is contained in:
2025-08-21 08:46:58 +02:00
parent 48574d634c
commit 8408f400c8
9 changed files with 29 additions and 34 deletions

View File

@@ -38,6 +38,7 @@ struct Process {
bool is_valid;
int exit_code;
char platform[6 * 8];
int64_t id;
int64_t view_id; // text editor view
bool scroll_to_end;

View File

@@ -216,15 +216,6 @@ FileIter IterateFiles(Allocator alo, String path) {
return it;
}
// struct Process {
// bool is_valid;
// int exit_code;
// char platform[6 * 8];
//
// int64_t view_id; // text editor view
// bool scroll_to_end;
// };
struct UnixProcess {
pid_t pid;
int child_stdout_read;
@@ -262,9 +253,6 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin
const int PIPE_WRITE = 1;
bool error = false;
printf("cmd = %.*s\n", FmtString(command_line));
printf("cwd = %.*s\n", FmtString(working_dir));
char *buffer = AllocArray(scratch, char, 4096);
chdir(working_dir.data);
getcwd(buffer, 4096);
@@ -285,7 +273,7 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin
posix_spawn_file_actions_t actions = {};
if (posix_spawn_file_actions_init(&actions) != 0) {
perror("posix_spawn_file_actions_init");
Error("Libc function failed: posix_spawn_file_actions_init, with error: %s", strerror(errno));
return process;
}
defer {
@@ -293,7 +281,7 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin
};
if (pipe(stdout_desc) == -1) {
perror("pipe");
Error("Libc function failed: pipe, with error: %s", strerror(errno));
return process;
}
defer {
@@ -306,7 +294,7 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin
};
if (pipe(stdin_desc) == -1) {
perror("pipe");
Error("Libc function failed: pipe, with error: %s", strerror(errno));
return process;
}
defer {
@@ -320,38 +308,38 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin
error = posix_spawn_file_actions_addclose(&actions, stdout_desc[PIPE_READ]) != 0;
if (error) {
perror("posix_spawn_file_actions_addclose");
Error("Libc function failed: posix_spawn_file_actions_addclose, with error: %s", strerror(errno));
return process;
}
error = posix_spawn_file_actions_adddup2(&actions, stdout_desc[PIPE_WRITE], STDOUT_FILENO) != 0;
if (error) {
perror("posix_spawn_file_actions_adddup2 STDOUT_FILENO");
Error("Libc function failed: posix_spawn_file_actions_adddup2 STDOUT_FILENO, with error: %s", strerror(errno));
return process;
}
error = posix_spawn_file_actions_adddup2(&actions, stdout_desc[PIPE_WRITE], STDERR_FILENO) != 0;
if (error) {
perror("posix_spawn_file_actions_adddup2 STDERR_FILENO");
Error("Libc function failed: posix_spawn_file_actions_adddup2 STDERR_FILENO, with error: %s", strerror(errno));
return process;
}
error = posix_spawn_file_actions_addclose(&actions, stdin_desc[PIPE_WRITE]) != 0;
if (error) {
perror("posix_spawn_file_actions_addclose");
Error("Libc function failed: posix_spawn_file_actions_addclose, with error: %s", strerror(errno));
return process;
}
error = posix_spawn_file_actions_adddup2(&actions, stdin_desc[PIPE_READ], STDIN_FILENO) != 0;
if (error) {
perror("posix_spawn_file_actions_adddup2 STDIN_FILENO");
Error("Libc function failed: posix_spawn_file_actions_adddup2 STDIN_FILENO, with error: %s", strerror(errno));
return process;
}
pid_t process_pid = 0;
error = posix_spawnp(&process_pid, args[0], &actions, NULL, args.data, env.data) != 0;
if (error) {
perror("failed to create process\n");
Error("Libc function failed: failed to create process\n, with error: %s", strerror(errno));
return process;
}
@@ -365,6 +353,7 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin
CloseStdin(&process);
}
process.id = process_pid;
process.is_valid = true;
return process;
}

View File

@@ -418,6 +418,7 @@ Process SpawnProcess(String command_line, String working_dir, String write_stdin
p->handle = info.hProcess;
process.is_valid = true;
process.id = (int64_t)p->handle;
if (write_stdin.len) {
WriteStdin(&process, write_stdin);