]> git.seodisparate.com - c_simple_http/commitdiff
Close read-pipe on xdg-mime's side in static.c
authorStephen Seo <seo.disparate@gmail.com>
Tue, 29 Oct 2024 04:45:38 +0000 (13:45 +0900)
committerStephen Seo <seo.disparate@gmail.com>
Tue, 29 Oct 2024 04:45:38 +0000 (13:45 +0900)
The pipe probably doesn't need to be closed since it is closed by
c_simple_http and the forked process stops while it is the only other
thing with that read-pipe-fd. However, it probably would be best to
close it so that during runtime all pipe fd's are closed after use.

src/static.c

index 68f5259cc590cedbe285fd709483304c36017a85..43f33bf193f53b60894a646fc386b3b1dc023618 100644 (file)
@@ -211,6 +211,9 @@ C_SIMPLE_HTTP_StaticFileInfo c_simple_http_get_file(const char *static_dir,
                                    from_xdg_mime_pipe[1],
                                    STDOUT_FILENO);
 
+  // Close "read" side of pipe on "xdg-mime"'s side.
+  posix_spawn_file_actions_addclose(actions, from_xdg_mime_pipe[0]);
+
   buf_size = 256;
   buf = malloc(buf_size);
   uint64_t buf_idx = 0;