aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMattias Andrée <maandree@member.fsf.org>2015-12-27 16:32:25 +0100
committerMattias Andrée <maandree@member.fsf.org>2015-12-27 16:32:25 +0100
commit16121571eddfa4cf03fc586ae5c2512705e9461f (patch)
treef644038dead107cdf5bed78653e83baf062d2b7f
parentdefine a feature-test macro (diff)
downloadunstickpixels-16121571eddfa4cf03fc586ae5c2512705e9461f.tar.gz
unstickpixels-16121571eddfa4cf03fc586ae5c2512705e9461f.tar.bz2
unstickpixels-16121571eddfa4cf03fc586ae5c2512705e9461f.tar.xz
clut could be left unrestored because of race condition
Signed-off-by: Mattias Andrée <maandree@member.fsf.org>
-rw-r--r--src/unstickpixels.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/unstickpixels.c b/src/unstickpixels.c
index 15b0d64..9a59aa3 100644
--- a/src/unstickpixels.c
+++ b/src/unstickpixels.c
@@ -17,6 +17,7 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define _XOPEN_SOURCE 700
+#define _DEFAULT_SOURCE
#include <stdio.h>
#include <unistd.h>
#include <stdlib.h>
@@ -202,11 +203,13 @@ static void usage(void)
*/
static void term_clut()
{
- size_t i;
+ size_t i, j;
+ if (clut_state == 2)
+ for (j = 0; j < 2; j++, usleep(1000000L / 10L))
+ for (i = 0; crtcs && crtcs[i]; i++, usleep(1000000L / 100L))
+ libgamma_crtc_set_gamma_ramps16(crtcs[i], *(ramps_saved[i]));
for (i = 0; crtcs && crtcs[i]; i++)
{
- if (clut_state == 2)
- libgamma_crtc_set_gamma_ramps16(crtcs[i], *(ramps_saved[i]));
libgamma_crtc_free(crtcs[i]);
libgamma_gamma_ramps16_free(ramps_red[i]);
libgamma_gamma_ramps16_free(ramps_green[i]);
@@ -463,6 +466,8 @@ int main(int argc, char* argv[])
fail:
saved_errno = errno;
+ printf("%s\033[?25h\033[H\033[2J", (started && vt) ? "\033]P0000000" : "");
+ fflush(stdout);
if (!vt)
term_clut();
errno = saved_errno;