39 #ifdef HAVE_SYS_TIME_H
46 static const char* lock_str =
"lock";
48 #if !defined(HAVE_PTHREAD)
50 #include <sys/types.h>
92 if (waitpid((pid_t)thread, &status, 0) == -1) {
98 lock_str, (
int)thread, status);
112 !pthread_attr_init(&attr)
113 && !pthread_attr_getstacksize(&attr, &stacksize)
114 && stacksize < ODS_MINIMUM_STACKSIZE
115 && !pthread_attr_setstacksize(&attr, ODS_MINIMUM_STACKSIZE)
118 ret = pthread_create(thr, attr_set?&attr:NULL, func, arg);
120 (void) pthread_attr_destroy(&attr);
123 ods_log_error(
"%s at %d could not pthread_create(thr, &attr, func, arg): %s",
124 __FILE__, __LINE__, strerror(ret));
131 ods_thread_wait(cond_basic_type* cond,
lock_basic_type* lock, time_t wait)
139 #ifndef HAVE_CLOCK_GETTIME
141 if (gettimeofday(&tv, NULL) != 0) {
146 ts.tv_sec = tv.tv_sec;
147 ts.tv_nsec = (tv.tv_usec/1000);
149 if (clock_gettime(CLOCK_REALTIME, &ts) < 0) {
157 ts.tv_sec = ts.tv_sec + wait;
158 ret = pthread_cond_timedwait(cond, lock, &ts);
160 ret = pthread_cond_wait(cond, lock);
163 if (ret == ETIMEDOUT) {
182 if((err=pthread_sigmask(SIG_SETMASK, &sigset, NULL)))
183 ods_fatal_exit(
"[%s] pthread_sigmask: %s", lock_str, strerror(err));
186 if(sigprocmask(SIG_SETMASK, &sigset, NULL) != 0)
187 ods_fatal_exit(
"[%s] sigprocmask: %s", lock_str, strerror(errno));
void ods_thread_blocksigs(void)
void ods_thr_fork_create(ods_thread_type *thr, void *(*func)(void *), void *arg)
void ods_fatal_exit(const char *format,...)
void ods_log_error(const char *format,...)
#define ods_thread_create(thr, func, arg)
void ods_log_warning(const char *format,...)
void ods_thr_fork_wait(ods_thread_type thread)