aboutsummaryrefslogtreecommitdiff
path: root/linux-bin/zzz.c
diff options
context:
space:
mode:
Diffstat (limited to 'linux-bin/zzz.c')
-rw-r--r--linux-bin/zzz.c18
1 files changed, 15 insertions, 3 deletions
diff --git a/linux-bin/zzz.c b/linux-bin/zzz.c
index 8bc3c22..479dd25 100644
--- a/linux-bin/zzz.c
+++ b/linux-bin/zzz.c
@@ -4,8 +4,10 @@
#include <fcntl.h>
#include <string.h>
#include <sys/types.h>
+#include <sys/wait.h>
#define POWER_STATE_F "/sys/power/state"
+#define SLEEP_TIMEOUT 30
void
die(const char *msg)
@@ -34,8 +36,6 @@ suspend()
n = write(fh, cmd, 3);
if (n == -1)
err("Writing to "POWER_STATE_F);
-
- exit(0);
}
int
@@ -84,7 +84,19 @@ main(int argc, char **argv)
execlp(lockProg, NULL);
err("execlp");
default:
- suspend();
+ for(;;) {
+ ret = 0;
+ ret = waitpid(pid, NULL, WNOHANG);
+
+ if (ret == 0) {
+ suspend();
+ sleep(SLEEP_TIMEOUT);
+ continue;
+ }
+
+ puts("exiting");
+ exit(0);
+ }
}
}