diff options
author | Marius Halden <marius.h@lden.org> | 2016-11-10 20:23:01 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2016-11-10 20:23:01 +0100 |
commit | f998babc5e8e421e38f22342ee3449f5c2996ceb (patch) | |
tree | 7a380e377f8145b79a4cc071070d850c81280a83 | |
parent | 85b43c98cef27668208874a91a3a9fc2a22d57c8 (diff) | |
download | runq-master.tar.gz runq-master.tar.bz2 runq-master.tar.xz |
-rw-r--r-- | newbatch.c | 24 |
1 files changed, 19 insertions, 5 deletions
@@ -17,16 +17,30 @@ main(int argc, char **argv) int64_t microtime; char *timestr = NULL, *queuedir = NULL, *tmpfile = NULL, *newfile = NULL; char buf[1024], *tmp; - int fd, l, m; - int perm = 0640; + int fd, l, m, ch; + int perm = 0640, exec = 0; + + while ((ch = getopt(argc, argv, "e")) != -1) { + switch (ch) { + case 'e': + exec = 1; + break; + default: + fprintf(stderr, "Usage: %s [-e] [dir]", argv[0]); + return 1; + } + } + + argc -= optind; + argv += optind; mypid = getpid(); gettimeofday(&tv, NULL); microtime = tv.tv_sec * 1000000 + tv.tv_usec; asprintf(×tr, "%li.%u", microtime, mypid); - if (argc > 1) { - queuedir = strdup(argv[1]); + if (argc >= 1) { + queuedir = strdup(argv[0]); } else { queuedir = strdup(DEFAULT_QUEUE_DIR); } @@ -36,7 +50,7 @@ main(int argc, char **argv) free(timestr); free(queuedir); - if (getenv("NEWBATCH_EXEC") != NULL) { + if (exec || getenv("NEWBATCH_EXEC") != NULL) { perm = 0750; } |