diff --git a/fuf.c b/fuf.c index c427688..5033162 100644 --- a/fuf.c +++ b/fuf.c @@ -59,6 +59,8 @@ handle_chld() static void handle_redraw() { + extern pthread_spinlock_t redraw_lock; + pthread_spin_lock(&redraw_lock); sendwin(); srefresh(); @@ -71,6 +73,7 @@ handle_redraw() cancel_preview(); refresh_layout(); } + pthread_spin_unlock(&redraw_lock); } static void @@ -113,6 +116,8 @@ init() init_colors(); /* init fuf */ + extern pthread_spinlock_t redraw_lock; /* not the right place for this */ + pthread_spin_init(&redraw_lock, PTHREAD_PROCESS_SHARED); /* , whatever */ handle_redraw(); start_load(load_items, display_load); init_preview(load_preview); diff --git a/inc/thr.c b/inc/thr.c index 3276e0d..69f4229 100644 --- a/inc/thr.c +++ b/inc/thr.c @@ -14,6 +14,7 @@ pthread_t preview_backup_thr; pthread_cond_t run_preview = PTHREAD_COND_INITIALIZER; pthread_mutex_t preview_lock = PTHREAD_MUTEX_INITIALIZER; pthread_mutex_t preview_pid_lock = PTHREAD_MUTEX_INITIALIZER; +pthread_spinlock_t redraw_lock; pid_t preview_pid[2]; _Atomic bool items_loading = false; _Atomic bool pn = false;