Skip to content

Commit e827baa

Browse files
committed
Fix --appimage-mount mountpoint communication
Right now, the buffering of stdout prevents proper reading of the mountpoint from stdout in scripts and other processes in general. This commit fixes the runtime's behavior.
1 parent 915b76d commit e827baa

File tree

1 file changed

+13
-3
lines changed

1 file changed

+13
-3
lines changed

src/runtime.c

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -868,13 +868,23 @@ int main(int argc, char *argv[]) {
868868
}
869869
real_argv[i] = NULL;
870870

871-
if(arg && strcmp(arg,"appimage-mount")==0) {
871+
if(arg && strcmp(arg, "appimage-mount") == 0) {
872872
char real_mount_dir[PATH_MAX];
873-
if (realpath(mount_dir, real_mount_dir) == real_mount_dir)
873+
874+
if (realpath(mount_dir, real_mount_dir) == real_mount_dir) {
874875
printf("%s\n", real_mount_dir);
875-
else
876+
} else {
876877
printf("%s\n", mount_dir);
878+
}
879+
880+
// stdout is, by default, buffered (unlike stderr), therefore in order to allow other processes to read
881+
// the path from stdout, we need to flush the buffers now
882+
// this is a less-invasive alternative to setbuf(stdout, NULL);
883+
fflush(stdout);
884+
877885
for (;;) pause();
886+
887+
exit(0);
878888
}
879889

880890
/* Setting some environment variables that the app "inside" might use */

0 commit comments

Comments
 (0)