diff options
author | Marius Halden <marius.h@lden.org> | 2016-11-04 14:02:37 +0100 |
---|---|---|
committer | Marius Halden <marius.h@lden.org> | 2016-11-04 14:02:37 +0100 |
commit | 40cf0121601f69a4f5c491ab1e2fd54bd7fe4b75 (patch) | |
tree | 0119b3b7b5c55aa81dbbed459ebc317a4d3c41cc /newbatch.c | |
parent | d7b994eccb760a68315fc48b1600f9164282a127 (diff) | |
download | runq-40cf0121601f69a4f5c491ab1e2fd54bd7fe4b75.tar.gz runq-40cf0121601f69a4f5c491ab1e2fd54bd7fe4b75.tar.bz2 runq-40cf0121601f69a4f5c491ab1e2fd54bd7fe4b75.tar.xz |
Initial for executing filedescriptor
Diffstat (limited to 'newbatch.c')
-rw-r--r-- | newbatch.c | 13 |
1 files changed, 12 insertions, 1 deletions
@@ -18,6 +18,7 @@ main(int argc, char **argv) char *timestr = NULL, *queuedir = NULL, *tmpfile = NULL, *newfile = NULL; char buf[1024], *tmp; int fd, l, m; + int perm = 0640; mypid = getpid(); gettimeofday(&tv, NULL); @@ -35,12 +36,19 @@ main(int argc, char **argv) free(timestr); free(queuedir); - fd = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, 0660); + if (getenv("NEWBATCH_EXEC") != NULL) { + perm = 0750; + } + + fd = open(tmpfile, O_WRONLY | O_CREAT | O_EXCL, perm); if (fd == -1) err(1, "open()"); while ((l = read(STDIN_FILENO, buf, sizeof(buf))) != 0) { if (l == -1) { + if (errno == EINTR) + continue; + unlink(tmpfile); err(1, NULL); } @@ -49,6 +57,9 @@ main(int argc, char **argv) while (l > 0) { m = write(fd, tmp, l); if (m == -1) { + if (errno == EINTR) + continue; + unlink(tmpfile); err(1, NULL); } |