diff options
author | Christian Neukirchen <chneukirchen@gmail.com> | 2015-08-03 13:26:25 +0200 |
---|---|---|
committer | Christian Neukirchen <chneukirchen@gmail.com> | 2015-08-03 13:26:25 +0200 |
commit | a8c5f2f79d773c98318f5f8708579845c7904140 (patch) | |
tree | bf76dbea2c554367a3179e2d8211bb616ecba648 | |
parent | 26d51d8d0a316885a4790a44e27572e5d121b2b3 (diff) | |
download | nq-a8c5f2f79d773c98318f5f8708579845c7904140.tar.gz nq-a8c5f2f79d773c98318f5f8708579845c7904140.tar.xz nq-a8c5f2f79d773c98318f5f8708579845c7904140.zip |
deal properly with int64_t values
-rw-r--r-- | nq.c | 12 |
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); |