From 90b866ea2b93f9186651fd540d91bdcc9a3abbc1 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Wed, 29 Jan 2020 19:40:57 +0100 Subject: [PATCH] mxqd: Use environment MXQ_JOB_TMPDIR 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. --- mxqd.c | 6 +++++- mxqsub.c | 2 +- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/mxqd.c b/mxqd.c index 412e43e3..aef3ab0d 100644 --- a/mxqd.c +++ b/mxqd.c @@ -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) { diff --git a/mxqsub.c b/mxqsub.c index f9c62b05..e9900d11 100644 --- a/mxqsub.c +++ b/mxqsub.c @@ -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"