[hackers] [dmenu] Replace deprecated usleep() with nanosleep() || Quentin Rameau

From: <git_AT_suckless.org>
Date: Mon, 28 Sep 2015 00:16:21 +0200 (CEST)

commit c42c3780274e6b12eaeab918cf7c13d2c36cf253
Author: Quentin Rameau <quinq_AT_fifth.space>
AuthorDate: Mon Sep 28 00:06:05 2015 +0200
Commit: Hiltjo Posthuma <hiltjo_AT_codemadness.org>
CommitDate: Mon Sep 28 00:15:13 2015 +0200

    Replace deprecated usleep() with nanosleep()

diff --git a/dmenu.c b/dmenu.c
index 49a6583..aa6e5d8 100644
--- a/dmenu.c
+++ b/dmenu.c
_AT_@ -6,7 +6,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <strings.h>
-#include <unistd.h>
+#include <time.h>
 #include <X11/Xlib.h>
 #include <X11/Xatom.h>
 #include <X11/Xutil.h>
_AT_@ -203,6 +203,7 @@ drawmenu(void)
 static void
 grabkeyboard(void)
 {
+ struct timespec ts = { .tv_sec = 1, .tv_nsec = 0 };
         int i;
 
         /* try to grab keyboard, we may have to wait for another process to ungrab */
_AT_@ -210,7 +211,7 @@ grabkeyboard(void)
                 if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True,
                                  GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
                         return;
- usleep(1000);
+ nanosleep(&ts, NULL);
         }
         die("cannot grab keyboard\n");
 }
Received on Mon Sep 28 2015 - 00:16:21 CEST

This archive was generated by hypermail 2.3.0 : Mon Sep 28 2015 - 00:24:12 CEST