Skip to content

Commit

Permalink
Merge pull request #37 from RyuzakiKK/close_fd
Browse files Browse the repository at this point in the history
flatpak-spawn: Close the file descriptors when are not needed anymore
  • Loading branch information
alexlarsson authored Oct 8, 2020
2 parents 9dc027d + a609fda commit 8b6b9df
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/flatpak-spawn.c
Original file line number Diff line number Diff line change
Expand Up @@ -520,6 +520,8 @@ add_paths_to_variant (GVariantBuilder *builder, GUnixFDList *fd_list, const GStr
g_printerr ("Failed to add fd to list for %s: %s\n", paths[i], error->message);
return FALSE;
}
/* The GUnixFdList keeps a duplicate, so we should release the original */
close (path_fd);
g_variant_builder_add (builder, "h", handle);
}

Expand Down Expand Up @@ -711,6 +713,8 @@ main (int argc,
g_printerr ("Can't append fd: %s\n", error->message);
return 1;
}
/* The GUnixFdList keeps a duplicate, so we should release the original */
close (fd);
g_variant_builder_add (fd_builder, "{uh}", fd, handle);
}

Expand Down Expand Up @@ -933,6 +937,10 @@ main (int argc,

g_debug ("child_pid: %d", child_pid);

/* Release our reference to the fds, so that only the copy we sent over
* D-Bus remains open */
g_clear_object (&fd_list);

loop = g_main_loop_new (NULL, FALSE);

g_signal_connect (session_bus, "closed", G_CALLBACK (session_bus_closed_cb), loop);
Expand Down

0 comments on commit 8b6b9df

Please sign in to comment.