Replace deprecated usleep() with nanosleep() c42c3780
Quentin Rameau · 2015-09-28 00:06 1 file(s) · +3 −2
dmenu.c +3 −2
6 6
#include <stdlib.h>
7 7
#include <string.h>
8 8
#include <strings.h>
9 -
#include <unistd.h>
9 +
#include <time.h>
10 10
#include <X11/Xlib.h>
11 11
#include <X11/Xatom.h>
12 12
#include <X11/Xutil.h>
203 203
static void
204 204
grabkeyboard(void)
205 205
{
206 +
	struct timespec ts = { .tv_sec = 1, .tv_nsec = 0  };
206 207
	int i;
207 208
208 209
	/* try to grab keyboard, we may have to wait for another process to ungrab */
210 211
		if (XGrabKeyboard(dpy, DefaultRootWindow(dpy), True,
211 212
		                 GrabModeAsync, GrabModeAsync, CurrentTime) == GrabSuccess)
212 213
			return;
213 -
		usleep(1000);
214 +
		nanosleep(&ts, NULL);
214 215
	}
215 216
	die("cannot grab keyboard\n");
216 217
}