From 7a71e241556197ee3ae10ab859843063125eca46 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 10:03:39 +0000 Subject: [PATCH 1/8] Initial plan From aac2e8b96df48fae4c5705417f78c406173e618f Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 10:11:30 +0000 Subject: [PATCH 2/8] Close keepalive pipe before execv to prevent FUSE daemon orphan Co-authored-by: probonopd <2480569+probonopd@users.noreply.github.com> --- src/runtime/runtime.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 2ebb3c8..71dec35 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -1846,6 +1846,9 @@ int main(int argc, char* argv[]) { strcpy(filename, mount_dir); strcat(filename, "/AppRun"); + /* Close the keepalive pipe before exec to ensure FUSE daemon terminates when we exit */ + close(keepalive_pipe[0]); + /* TODO: Find a way to get the exit status and/or output of this */ execv(filename, real_argv); /* Error if we continue here */ From 3828d3ad6c42a00dc555f571dfb9e7f8f983f0f6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 10:13:36 +0000 Subject: [PATCH 3/8] Final verification and documentation Co-authored-by: probonopd <2480569+probonopd@users.noreply.github.com> --- _codeql_detected_source_root | 1 + 1 file changed, 1 insertion(+) create mode 120000 _codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root new file mode 120000 index 0000000..e2dfd84 --- /dev/null +++ b/_codeql_detected_source_root @@ -0,0 +1 @@ +./src/runtime \ No newline at end of file From adc00d44b24396a34e6b9f3e0834516e6675840e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 10:14:27 +0000 Subject: [PATCH 4/8] Remove codeql artifact and add to gitignore Co-authored-by: probonopd <2480569+probonopd@users.noreply.github.com> --- .gitignore | 1 + _codeql_detected_source_root | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) delete mode 120000 _codeql_detected_source_root diff --git a/.gitignore b/.gitignore index e4166e7..db17f57 100644 --- a/.gitignore +++ b/.gitignore @@ -67,3 +67,4 @@ squashfs-root/ # build products src/runtime/runtime +_codeql_detected_source_root diff --git a/_codeql_detected_source_root b/_codeql_detected_source_root deleted file mode 120000 index e2dfd84..0000000 --- a/_codeql_detected_source_root +++ /dev/null @@ -1 +0,0 @@ -./src/runtime \ No newline at end of file From 2442c307fe7739f89a5741b7ca1b5628894445fd Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 10:45:08 +0000 Subject: [PATCH 5/8] Fork before exec to close keepalive pipe after AppRun exits Co-authored-by: probonopd <2480569+probonopd@users.noreply.github.com> --- src/runtime/runtime.c | 37 ++++++++++++++++++++++++++++++------- 1 file changed, 30 insertions(+), 7 deletions(-) diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 71dec35..f0c85b8 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -1846,14 +1846,37 @@ int main(int argc, char* argv[]) { strcpy(filename, mount_dir); strcat(filename, "/AppRun"); - /* Close the keepalive pipe before exec to ensure FUSE daemon terminates when we exit */ - close(keepalive_pipe[0]); + /* Fork before exec to ensure we can close the keepalive pipe after AppRun exits */ + pid_t apprun_pid = fork(); + if (apprun_pid == -1) { + perror("fork error"); + exit(EXIT_EXECERROR); + } - /* TODO: Find a way to get the exit status and/or output of this */ - execv(filename, real_argv); - /* Error if we continue here */ - perror("execv error"); - exit(EXIT_EXECERROR); + if (apprun_pid == 0) { + /* Child process - exec AppRun */ + execv(filename, real_argv); + /* Error if we continue here */ + perror("execv error"); + exit(EXIT_EXECERROR); + } else { + /* Parent process - wait for AppRun to finish, then close pipe */ + int status; + waitpid(apprun_pid, &status, 0); + + /* Close the keepalive pipe after AppRun exits to terminate FUSE daemon */ + close(keepalive_pipe[0]); + + /* Exit with the same status as AppRun */ + if (WIFEXITED(status)) { + exit(WEXITSTATUS(status)); + } else if (WIFSIGNALED(status)) { + /* Child was killed by a signal, exit with 128 + signal number */ + exit(128 + WTERMSIG(status)); + } else { + exit(EXIT_EXECERROR); + } + } } return 0; From 876881d7469aa2d6944dbcaac582143051c313c6 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sat, 8 Nov 2025 11:15:01 +0000 Subject: [PATCH 6/8] Address code review feedback: close pipes, check waitpid, fix memory leak Co-authored-by: probonopd <2480569+probonopd@users.noreply.github.com> --- src/runtime/runtime.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index f0c85b8..fa34cae 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -1854,7 +1854,11 @@ int main(int argc, char* argv[]) { } if (apprun_pid == 0) { - /* Child process - exec AppRun */ + /* Child process - close keepalive pipe before exec */ + close(keepalive_pipe[0]); + close(keepalive_pipe[1]); + + /* exec AppRun */ execv(filename, real_argv); /* Error if we continue here */ perror("execv error"); @@ -1862,11 +1866,20 @@ int main(int argc, char* argv[]) { } else { /* Parent process - wait for AppRun to finish, then close pipe */ int status; - waitpid(apprun_pid, &status, 0); + pid_t waited_pid = waitpid(apprun_pid, &status, 0); + if (waited_pid == -1) { + perror("waitpid error"); + close(keepalive_pipe[0]); + free(real_argv); + exit(EXIT_EXECERROR); + } /* Close the keepalive pipe after AppRun exits to terminate FUSE daemon */ close(keepalive_pipe[0]); + /* Free allocated memory before exit */ + free(real_argv); + /* Exit with the same status as AppRun */ if (WIFEXITED(status)) { exit(WEXITSTATUS(status)); From f66ad0d5753d529a3409da7e6224ca4083fc09d9 Mon Sep 17 00:00:00 2001 From: probonopd Date: Sat, 8 Nov 2025 12:59:56 +0100 Subject: [PATCH 7/8] Update src/runtime/runtime.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/runtime/runtime.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index fa34cae..83f049d 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -1856,7 +1856,6 @@ int main(int argc, char* argv[]) { if (apprun_pid == 0) { /* Child process - close keepalive pipe before exec */ close(keepalive_pipe[0]); - close(keepalive_pipe[1]); /* exec AppRun */ execv(filename, real_argv); From 38a08cc4743bb6b885c6e242843bdf2b8b9f51e7 Mon Sep 17 00:00:00 2001 From: probonopd Date: Sat, 8 Nov 2025 13:00:05 +0100 Subject: [PATCH 8/8] Update src/runtime/runtime.c Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> --- src/runtime/runtime.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/runtime/runtime.c b/src/runtime/runtime.c index 83f049d..e3ba402 100644 --- a/src/runtime/runtime.c +++ b/src/runtime/runtime.c @@ -1865,7 +1865,10 @@ int main(int argc, char* argv[]) { } else { /* Parent process - wait for AppRun to finish, then close pipe */ int status; - pid_t waited_pid = waitpid(apprun_pid, &status, 0); + pid_t waited_pid; + do { + waited_pid = waitpid(apprun_pid, &status, 0); + } while (waited_pid == -1 && errno == EINTR); if (waited_pid == -1) { perror("waitpid error"); close(keepalive_pipe[0]);