Skip to content

Commit

Permalink
Remove all warnings, make POSIX compatible.
Browse files Browse the repository at this point in the history
  • Loading branch information
theomega committed Dec 11, 2011
1 parent 240aeeb commit 1771f61
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

CFLAGS = -std=c99
CFLAGS = -std=c99 -D_POSIX_C_SOURCE=199309L -Wall -pedantic
PREFIX = /usr/local

watch: src/watch.c
Expand All @@ -14,4 +14,4 @@ uninstall:
clean:
rm -f watch

.PHONY: clean install uninstall
.PHONY: clean install uninstall
14 changes: 11 additions & 3 deletions src/watch.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
#include <stdlib.h>
#include <string.h>
#include <unistd.h>
#include <time.h>

#include <fcntl.h>
#include <sys/wait.h>

Expand Down Expand Up @@ -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;
}

/*
Expand Down Expand Up @@ -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];
Expand Down Expand Up @@ -198,4 +206,4 @@ main(int argc, const char **argv){
}

return 0;
}
}

0 comments on commit 1771f61

Please sign in to comment.