Skip to content

Commit

Permalink
mxqd: Use environment MXQ_JOB_TMPDIR
Browse files Browse the repository at this point in the history
It might be usefull for a  script to know, if it has a job-specific
temporary filesystem or not.

If the job was submitted with --tmpdir then set both MXQ_JOB_TMPDIR and
TMPDIR to the path of the temporary space.

If a program is run without --tmpdir or outside of mxqd, then TMPDIR
usually points to some (non-private) temporary space as well, but
MXQ_JOB_TMPDIR will not be set.
  • Loading branch information
donald committed Jan 29, 2020
1 parent 81e49c9 commit 90b866e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 5 additions & 1 deletion mxqd.c
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,11 @@ static int init_child_process(struct mxq_group_list *glist, struct mxq_job *job)
if (group->job_tmpdir_size == 0) {
mx_setenv_forever("TMPDIR", server->initial_tmpdir);
} else {
mx_setenvf_forever("TMPDIR", "%s/%lu", MXQ_JOB_TMPDIR_MNTDIR, job->job_id);
char *mxq_job_tmpdir;
mx_asprintf_forever(&mxq_job_tmpdir, "%s/%lu", MXQ_JOB_TMPDIR_MNTDIR, job->job_id);
mx_setenv_forever("MXQ_JOB_TMPDIR", mxq_job_tmpdir);
mx_setenv_forever("TMPDIR", mxq_job_tmpdir);
free(mxq_job_tmpdir);
}
fh = open("/proc/self/loginuid", O_WRONLY|O_TRUNC);
if (fh == -1) {
Expand Down
2 changes: 1 addition & 1 deletion mxqsub.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ static void print_usage(void)
"\n"
" -j, --threads=NUMBER set number of threads (default: 1)\n"
" -m, --memory=SIZE set amount of memory (default: 2G)\n"
" --tmpdir=SIZE set size of TMPDIR (default: 0)\n"
" --tmpdir=SIZE set size of MXQ_JOB_TMPDIR (default: 0)\n"
"\n"
" [SIZE] may be suffixed with a combination of T, G and M\n"
" to specify tebibytes, gibibytes and mebibytes.\n"
Expand Down

0 comments on commit 90b866e

Please sign in to comment.