+static size_t tracked_fds_list_space;
+
+
+#ifdef DEBUG
+static void tracked_fds_debug(void) {
+ size_t i;
+
+ for (i = 0; i < TRACKFDS_STATIC_COUNT; i++) {
+ if (tracked_fds[i]) {
+ debug(" tracked_fds[%d]: %d\n", i, tracked_fds[i]);
+ }
+ }
+ debug(" tracked_fds_list: %d/%d\t[%d]\n", tracked_fds_list_count,
+ tracked_fds_list_space,
+ getpid());
+ for (i = 0; i < tracked_fds_list_count; i++) {
+ debug(" tracked_fds_list[%d]: %d\n", i, tracked_fds_list[i]);
+ }
+}
+#endif
+
+/* Check if filename occurs in the comma-separated list ignore. */
+static int is_program_ignored(char const *filename, char const *ignore) {
+ size_t length;
+ size_t filename_length = strlen(filename);
+
+#ifdef DEBUG
+ debug(" is_program_ignored(\"%s\", \"%s\")\n", filename, ignore);
+#endif
+
+ for (; *ignore; ignore += length) {
+ while (*ignore == ',') {
+ ignore++;
+ }
+
+ length = strcspn(ignore, ",");
+ if (length == 0) {
+ break;
+ }
+
+ if (length != filename_length) {
+ continue;
+ }
+ if (!strncmp(filename, ignore, length)) {
+ return 1;
+ }
+ }
+
+ return 0;
+}
+
+static int init_tracked_fds_list(size_t count) {
+ assert(count > 0);
+
+ /* Reduce reallocs. */
+ count += TRACKFDS_REALLOC_STEP;