Handle the case where the threads aren't initialized
authoraland <aland>
Tue, 15 Feb 2005 01:19:22 +0000 (01:19 +0000)
committeraland <aland>
Tue, 15 Feb 2005 01:19:22 +0000 (01:19 +0000)
src/main/threads.c

index 86fe578..56c190f 100644 (file)
@@ -1115,7 +1115,9 @@ pid_t rad_waitpid(pid_t pid, int *status, int options)
 {
        int i, rcode;
        int found;
-       pthread_t self = pthread_self();
+       pthread_t self;
+
+       if (!exec_initialized) return waitpid(pid, status, options);
 
        /*
         *      We're only allowed to wait for a SPECIFIC pid.
@@ -1124,6 +1126,8 @@ pid_t rad_waitpid(pid_t pid, int *status, int options)
                return -1;
        }
 
+       self = pthread_self();
+
        /*
         *      Find the PID to wait for, starting at an index within
         *      the array.  This makes the lookups O(1) on average,
@@ -1201,6 +1205,8 @@ int rad_savepid(pid_t pid, int status)
 {
        int i;
 
+       if (!exec_initialized) return 0;
+
        /*
         *      Find the PID to wait for, starting at an index within
         *      the array.  This makes the lookups O(1) on average,