$NetBSD$

--- eval.c.orig	2009-12-21 08:11:42.000000000 +0000
+++ eval.c
@@ -12329,6 +12329,18 @@ thread_timer(dummy)
     return NULL;
 }
 
+/* fix inconsistent data */
+static void
+rb_thread_stop_timer_atfork(void)
+{
+    if (!thread_init) return;
+#if !defined(__NetBSD__)
+    (void)pthread_cond_init(&time_thread.cond, NULL);
+    (void)pthread_mutex_init(&time_thread.lock, NULL);
+#endif
+    thread_init = 0;
+}
+
 void
 rb_thread_start_timer()
 {
@@ -12343,7 +12355,7 @@ rb_thread_start_timer()
     safe_mutex_lock(&time_thread.lock);
     if (pthread_create(&time_thread.thread, 0, thread_timer, args) == 0) {
 	thread_init = 1;
-	pthread_atfork(0, 0, rb_thread_stop_timer);
+	pthread_atfork(0, 0, rb_thread_stop_timer_atfork);
 	pthread_cond_wait(&start, &time_thread.lock);
     }
     pthread_cleanup_pop(1);
@@ -12353,11 +12365,15 @@ void
 rb_thread_stop_timer()
 {
     if (!thread_init) return;
+#if !defined(__NetBSD__)
     safe_mutex_lock(&time_thread.lock);
     pthread_cond_signal(&time_thread.cond);
     thread_init = 0;
     pthread_cleanup_pop(1);
     pthread_join(time_thread.thread, NULL);
+#else
+    thread_init = 0;
+#endif
 }
 #elif defined(HAVE_SETITIMER)
 static void
