Permalink
Browse files

Remove all warnings, make POSIX compatible.

  • Loading branch information...
1 parent 240aeeb commit 1771f611db4c514631cad76b84265122a877e1e8 @theomega theomega committed Dec 11, 2011
Showing with 13 additions and 5 deletions.
  1. +2 −2 Makefile
  2. +11 −3 src/watch.c
View
@@ -1,5 +1,5 @@
-CFLAGS = -std=c99
+CFLAGS = -std=c99 -D_POSIX_C_SOURCE=199309L -Wall -pedantic
PREFIX = /usr/local
watch: src/watch.c
@@ -14,4 +14,4 @@ uninstall:
clean:
rm -f watch
-.PHONY: clean install uninstall
+.PHONY: clean install uninstall
View
@@ -9,6 +9,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
+#include <time.h>
+
#include <fcntl.h>
#include <sys/wait.h>
@@ -73,7 +75,13 @@ milliseconds(const char *str) {
void
mssleep(int ms) {
- usleep(ms * 1000);
+ struct timespec req={0};
+ time_t sec=(int)(ms/1000);
+ ms=ms-(sec*1000);
+ req.tv_sec=sec;
+ req.tv_nsec=ms*1000000L;
+ while(nanosleep(&req,&req)==-1)
+ continue;
}
/*
@@ -109,7 +117,7 @@ main(int argc, const char **argv){
int interval = DEFAULT_INTERVAL;
int len = 0;
- char *args[ARGS_MAX] = {};
+ char *args[ARGS_MAX] = {0};
for (int i = 1; i < argc; ++i) {
const char *arg = argv[i];
@@ -198,4 +206,4 @@ main(int argc, const char **argv){
}
return 0;
-}
+}

0 comments on commit 1771f61

Please sign in to comment.