/* Was ENV_NAME_FDS found and used when init_from_environment() was called?
* This is not true if the process set it manually after initialization. */
static int used_fds_set_by_user;
+/* Was any of our handle_*_pre()/handle_*_post() functions called recursively?
+ * If so don't print the pre/post string for the recursive calls. This is
+ * necessary on some systems (e.g. FreeBSD 9.1) which call multiple hooked
+ * functions while printing a string (e.g. a FILE * and a fd hook function is
+ * called). */
+static int handle_recursive;
#include "constants.h"
static void handle_file_post(FILE *stream) noinline;
static void handle_fd_pre(int fd) {
+ if (handle_recursive++ > 0) {
+ return;
+ }
+
int saved_errno = errno;
if (unlikely(!pre_string || !post_string)) {
errno = saved_errno;
}
static void handle_fd_post(int fd) {
+ if (--handle_recursive > 0) {
+ return;
+ }
+
int saved_errno = errno;
/* write() already loaded above in handle_fd_pre(). */
}
static void handle_file_pre(FILE *stream) {
+ if (handle_recursive++ > 0) {
+ return;
+ }
+
int saved_errno = errno;
if (unlikely(!pre_string || !post_string)) {
errno = saved_errno;
}
static void handle_file_post(FILE *stream) {
+ if (--handle_recursive > 0) {
+ return;
+ }
+
int saved_errno = errno;
/* fwrite() already loaded above in handle_file_pre(). */