-
Notifications
You must be signed in to change notification settings - Fork 27
Fix orphaned FUSE daemon process after AppImage exit #138
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?
Changes from 5 commits
7a71e24
aac2e8b
3828d3a
adc00d4
2442c30
876881d
f66ad0d
38a08cc
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,3 +67,4 @@ squashfs-root/ | |
|
|
||
| # build products | ||
| src/runtime/runtime | ||
| _codeql_detected_source_root | ||
| Original file line number | Diff line number | Diff line change | ||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -1846,11 +1846,37 @@ int main(int argc, char* argv[]) { | |||||||||||||||
| strcpy(filename, mount_dir); | ||||||||||||||||
| strcat(filename, "/AppRun"); | ||||||||||||||||
|
|
||||||||||||||||
| /* 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); | ||||||||||||||||
| /* 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); | ||||||||||||||||
| } | ||||||||||||||||
|
|
||||||||||||||||
| 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); | ||||||||||||||||
|
||||||||||||||||
| 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]); | |
| exit(EXIT_EXECERROR); | |
| } |
Copilot
AI
Nov 8, 2025
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.
The memory allocated for real_argv on line 1807 is never freed before these exit calls, causing a memory leak. While the process is exiting anyway, it's better practice to free(real_argv) before the exit calls or restructure to ensure cleanup happens.
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.
The child process inherits both ends of the keepalive pipe but doesn't use them. Both pipe ends should be closed before execv() to prevent the child from holding unnecessary file descriptors. Add
close(keepalive_pipe[0]);andclose(keepalive_pipe[1]);before the execv call on line 1858.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 seems like an obvious oversight that was there before. I am just a little concerned that the pipe loses its usefulness when it is closed here already. (Yes, technically the parent process would keep its side open anyway).
This needs to be tested thoroughly. The nature of the bug requires a quite sophisticated setup, though, which is time consuming.