about summary refs log tree commit diff
path: root/nq.c
diff options
context:
space:
mode:
authorChristian Neukirchen <chneukirchen@gmail.com>2015-08-03 13:26:25 +0200
committerChristian Neukirchen <chneukirchen@gmail.com>2015-08-03 13:26:25 +0200
commita8c5f2f79d773c98318f5f8708579845c7904140 (patch)
treebf76dbea2c554367a3179e2d8211bb616ecba648 /nq.c
parent26d51d8d0a316885a4790a44e27572e5d121b2b3 (diff)
downloadnq-a8c5f2f79d773c98318f5f8708579845c7904140.tar.gz
nq-a8c5f2f79d773c98318f5f8708579845c7904140.tar.xz
nq-a8c5f2f79d773c98318f5f8708579845c7904140.zip
deal properly with int64_t values
Diffstat (limited to 'nq.c')
-rw-r--r--nq.c12
1 files changed, 7 insertions, 5 deletions
diff --git a/nq.c b/nq.c
index edc338e..0bbb009 100644
--- a/nq.c
+++ b/nq.c
@@ -30,8 +30,9 @@
 #include <dirent.h>
 #include <errno.h>
 #include <fcntl.h>
-#include <stdio.h>
+#include <inttypes.h>
 #include <stdint.h>
+#include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
 #include <time.h>
@@ -71,9 +72,10 @@ write_execline(int fd, int argc, char *argv[])
 int
 main(int argc, char *argv[])
 {
+	int64_t ms;
 	int dirfd = 0, lockfd = 0, opt = 0, tflag = 0, wflag = 0;
 	int pipefd[2];
-	char lockfile[32];
+	char lockfile[64];
 	pid_t child;
 	struct timeval started;
 	struct dirent *ent;
@@ -81,7 +83,7 @@ main(int argc, char *argv[])
 
 	/* timestamp is milliseconds since epoch.  */
 	gettimeofday(&started, NULL);
-	int64_t ms = started.tv_sec*1000 + started.tv_usec/1000;
+	ms = started.tv_sec*1000 + started.tv_usec/1000;
 
 	while ((opt = getopt(argc, argv, "+htw")) != -1) {
 		switch (opt) {
@@ -114,7 +116,7 @@ usage:
 	}
 
 	if (tflag || wflag) {
-		sprintf(lockfile, ".,%011lx.%d", ms, getpid());
+		sprintf(lockfile, ".,%011" PRIx64 ".%d", ms, getpid());
 		goto wait;
 	}
 
@@ -148,7 +150,7 @@ usage:
 		int status;
 
 		/* output expected lockfile name.  */
-		sprintf(lockfile, ",%011lx.%d", ms, child);
+		sprintf(lockfile, ",%011" PRIx64 ".%d", ms, child);
 		dprintf(1, "%s\n", lockfile);
 		close(0);
 		close(1);