From e3af0032b236dc52d4a74c4d740e57a1f6d520aa Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Sat, 7 Nov 2009 18:55:16 +0100 Subject: set the close-on-exec flag on all file descriptors Added the "fd_util" library, which attempts to use the new thread-safe Linux system calls pipe2(), accept4() and the options O_CLOEXEC, SOCK_CLOEXEC. Without these, it falls back to FD_CLOEXEC, which is not thread safe. This is particularly important for the "pipe" output plugin (and others, such as JACK/PulseAudio), because we were heavily leaking file descriptors to child processes. --- Makefile.am | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index 3ba6613f8..542049be2 100644 --- a/Makefile.am +++ b/Makefile.am @@ -72,6 +72,7 @@ mpd_headers = \ src/encoder_list.h \ src/encoder_api.h \ src/exclude.h \ + src/fd_util.h \ src/fifo_buffer.h \ src/update.h \ src/update_internal.h \ @@ -220,6 +221,7 @@ src_mpd_SOURCES = \ src/database.c \ src/dirvec.c \ src/exclude.c \ + src/fd_util.c \ src/fifo_buffer.c \ src/filter_plugin.c \ src/filter_registry.c \ @@ -738,6 +740,7 @@ test_run_input_LDADD = $(MPD_LIBS) \ test_run_input_SOURCES = test/run_input.c \ src/conf.c src/tokenizer.c src/utils.c \ src/tag.c src/tag_pool.c src/tag_save.c \ + src/fd_util.c \ $(ARCHIVE_SRC) \ $(INPUT_SRC) @@ -753,6 +756,7 @@ test_dump_playlist_SOURCES = test/dump_playlist.c \ src/uri.c \ src/song.c src/tag.c src/tag_pool.c src/tag_save.c \ src/text_input_stream.c src/fifo_buffer.c \ + src/fd_util.c \ $(ARCHIVE_SRC) \ $(INPUT_SRC) \ $(PLAYLIST_SRC) @@ -771,6 +775,7 @@ test_run_decoder_SOURCES = test/run_decoder.c \ src/tag.c src/tag_pool.c \ src/replay_gain.c \ src/uri.c \ + src/fd_util.c \ $(ARCHIVE_SRC) \ $(INPUT_SRC) \ $(TAG_SRC) \ @@ -790,6 +795,7 @@ test_read_tags_SOURCES = test/read_tags.c \ src/tag.c src/tag_pool.c \ src/replay_gain.c \ src/uri.c \ + src/fd_util.c \ $(ARCHIVE_SRC) \ $(INPUT_SRC) \ $(TAG_SRC) \ @@ -857,6 +863,7 @@ test_run_output_SOURCES = test/run_output.c \ src/filter/convert_filter_plugin.c \ src/filter/volume_filter_plugin.c \ src/pcm_volume.c \ + src/fd_util.c \ $(OUTPUT_SRC) test_read_mixer_CPPFLAGS = $(AM_CPPFLAGS) \ @@ -869,6 +876,7 @@ test_read_mixer_SOURCES = test/read_mixer.c \ src/mixer_control.c src/mixer_api.c \ src/filter_plugin.c \ src/filter/volume_filter_plugin.c \ + src/fd_util.c \ $(MIXER_SRC) endif -- cgit v1.2.3