Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

merge

  • Loading branch information...
commit 421c8b2f3f9f49e427ae47d376c27a9635ec350a 2 parents 14b0724 + 1771f61
TJ Holowaychuk authored

Showing 2 changed files with 9 additions and 3 deletions. Show diff stats Hide diff stats

  1. +2 2 Makefile
  2. +7 1 src/watch.c
4 Makefile
... ... @@ -1,5 +1,5 @@
1 1
2   -CFLAGS = -std=c99 -Wall -pedantic
  2 +CFLAGS = -std=c99 -D_POSIX_C_SOURCE=199309L -Wall -pedantic
3 3 PREFIX = /usr/local
4 4
5 5 watch: src/watch.c
@@ -14,4 +14,4 @@ uninstall:
14 14 clean:
15 15 rm -f watch
16 16
17   -.PHONY: clean install uninstall
  17 +.PHONY: clean install uninstall
8 src/watch.c
@@ -9,6 +9,7 @@
9 9 #include <stdlib.h>
10 10 #include <string.h>
11 11 #include <unistd.h>
  12 +#include <time.h>
12 13 #include <fcntl.h>
13 14 #include <sys/wait.h>
14 15
@@ -73,7 +74,12 @@ milliseconds(const char *str) {
73 74
74 75 void
75 76 mssleep(int ms) {
76   - usleep(ms * 1000);
  77 + struct timespec req = {0};
  78 + time_t sec = (int)(ms / 1000);
  79 + ms = ms -(sec * 1000);
  80 + req.tv_sec = sec;
  81 + req.tv_nsec = ms * 1000000L;
  82 + while(-1 == nanosleep(&req, &req)) ;
77 83 }
78 84
79 85 /*

0 comments on commit 421c8b2

Please sign in to comment.
Something went wrong with that request. Please try again.