-
Notifications
You must be signed in to change notification settings - Fork 15
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sometimes hhpc is so much hungry that it eats my pointer #9
Comments
That's definitely not good at all. Could you run hhpc verbosely with the |
I've finally managed to catch it 🎯
|
This seems related to the If nanosleep is interupted it will return early with a return value of From there you set the global state of while (working && grabPointer(dpy, win, emptyCursor, mask)) { always fails. This is speculation though, I have experienced this as well but didn't think to |
As a follow up, I can manually set |
Here is an untested potential fix for this, it basically just continues after [Edit: I could make this a Pull Request if you wish.] diff --git a/hhpc.c b/hhpc.c
index f106f7f..54e5dc8 100644
--- a/hhpc.c
+++ b/hhpc.c
@@ -38,6 +38,7 @@
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
static int gIdleTimeout = 1;
static int gVerbose = 0;
@@ -90,8 +91,11 @@ static void delay(time_t sec, long msec) {
sleep.tv_sec = sec;
sleep.tv_nsec = (msec % 1000) * 1000 * 1000;
- if (nanosleep(&sleep, NULL) == -1) {
- signalHandler(0);
+ while (nanosleep(&sleep, &sleep) != 0) {
+ if (errno == EINTR)
+ continue;
+ else
+ signalHandler(0);
}
} |
Hm, this may not be the cause as I suspected, although it does fix one error case. It seems to get stuck in |
This might be a
|
Okay, well I seem to have "fixed" this by simply adding a timeout on the diff --git a/hhpc.c b/hhpc.c
index f106f7f..84f6cc0 100644
--- a/hhpc.c
+++ b/hhpc.c
@@ -193,7 +193,15 @@ static void waitForMotion(Display *dpy, Window win, int timeout) {
* is interruptible by signals, which allows ctrl+c to work. If we
* were to just use XNextEvent() (which blocks), ctrl+c would not
* work. */
- ready = select(xfd + 1, &fds, NULL, NULL, NULL);
+ struct timeval tv = {5, 0}; /* waits 5 seconds */
+
+ if ((ready = select(xfd + 1, &fds, NULL, NULL, &tv)) == -1) {
+ if (working) perror("hhpc: error while select()'ing");
+ }
+
+ if (ready == 0) {
+ if (gVerbose) fprintf(stderr, "hhpc: timeout\n");
+ }
if (ready > 0) {
if (gVerbose) fprintf(stderr, "hhpc: event received, ungrabbing and sleeping\n");
@@ -211,12 +219,6 @@ static void waitForMotion(Display *dpy, Window win, int timeout) {
delay(timeout, 0);
}
- else if (ready == 0) {
- if (gVerbose) fprintf(stderr, "hhpc: timeout\n");
- }
- else {
- if (working) perror("hhpc: error while select()'ing");
- }
}
XUngrabPointer(dpy, CurrentTime); I placed a 5 second timeout and this is the result after experiencing a
|
can confirm this happens for me too. i am currently working around it manually by running |
I couldn't find anything about the nutritional values of a pointer but I guess it's not much healthy for hhpc.
It just happens randomly, I can get it back after killing hhpc :(
The text was updated successfully, but these errors were encountered: