diff --git a/src/common/log.c b/src/common/log.c
index 928c420be003ebc99a428987f149bcc079f33d39..5aa60c15e5a9d1a6d4d525eaa69f74e5a92aff99 100644
--- a/src/common/log.c
+++ b/src/common/log.c
@@ -151,10 +151,12 @@ extern char * program_invocation_name;
 static void _atfork_prep()   { if (log) slurm_mutex_lock(&log_lock);   }
 static void _atfork_parent() { if (log) slurm_mutex_unlock(&log_lock); }
 static void _atfork_child()  { if (log) slurm_mutex_init(&log_lock);   }
+static bool at_forked = false;
 #  define atfork_install_handlers()                                           \
-          do {                                                                \
+          while (!at_forked) {                                                \
                 pthread_atfork(_atfork_prep, _atfork_parent, _atfork_child);  \
-	  } while (0)
+		at_forked = true;                                             \
+	  }
 #else 
 #  define atfork_install_handlers() (NULL)
 #endif