summaryrefslogtreecommitdiffstats
path: root/newbatch.c
diff options
context:
space:
mode:
authorMarius Halden <marius.h@lden.org>2016-11-10 20:23:01 +0100
committerMarius Halden <marius.h@lden.org>2016-11-10 20:23:01 +0100
commitf998babc5e8e421e38f22342ee3449f5c2996ceb (patch)
tree7a380e377f8145b79a4cc071070d850c81280a83 /newbatch.c
parent85b43c98cef27668208874a91a3a9fc2a22d57c8 (diff)
downloadrunq-master.tar.gz
runq-master.tar.bz2
runq-master.tar.xz
Add flag to newbatch to make jobs executableHEADmaster
Diffstat (limited to 'newbatch.c')
-rw-r--r--newbatch.c24
1 files changed, 19 insertions, 5 deletions
diff --git a/newbatch.c b/newbatch.c
index 0bac7ee..45de7b9 100644
--- a/newbatch.c
+++ b/newbatch.c
@@ -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(&timestr, "%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;
}