diff --git a/doc/man/man1/sbatch.1 b/doc/man/man1/sbatch.1 index 61dbfa723b103ab5fb368e13c6dda512413f3410..81441ee268f801486df08ecbc6d51f491aaa4fd9 100644 --- a/doc/man/man1/sbatch.1 +++ b/doc/man/man1/sbatch.1 @@ -376,12 +376,12 @@ option will implicitly be set to load other environment variables based upon the user's configuration on the cluster which executes the job. .TP -\fB\-\-export\-file\fR=<\fIfilename\fR | \fIpipe_fd\fR> +\fB\-\-export\-file\fR=<\fIfilename\fR | \fIfd\fR> If a number between 3 and OPEN_MAX is specified as the argument to -this option, a pipe's read file descriptor will be assumed (STDIN and +this option, a readable file descriptor will be assumed (STDIN and STDOUT are not supported as valid arguments). Otherwise a filename is assumed. Export environment variables defined in <\fIfilename\fR> or -read from <\fIpipe_fd\fR> to the job's execution environment. The +read from <\fIfd\fR> to the job's execution environment. The content is one or more environment variable definitions of the form NAME=value, each separated by a null character. This allows the use of special characters in environment definitions. The diff --git a/src/common/env.c b/src/common/env.c index 529f1af49503dc1ade78ccfaf044c1ae3d4729d7..19e32418cdd8c25f30823c4d761487ae19c1363f 100644 --- a/src/common/env.c +++ b/src/common/env.c @@ -1581,9 +1581,9 @@ static int _bracket_cnt(char *value) } /* - * Load user environment from a specified file or pipe. + * Load user environment from a specified file or file descriptor. * - * This will read in a user specified file or pipe, that is invoked + * This will read in a user specified file or fd, that is invoked * via the --export-file option in sbatch. The NAME=value entries must * be NULL separated to support special characters in the environment * definitions. @@ -1596,7 +1596,7 @@ static int _bracket_cnt(char *value) char **env_array_from_file(const char *fname) { char *buf = NULL, *ptr = NULL, *eptr = NULL; - char *line, *value, *p; + char *value, *p; char **env = NULL; char name[256]; int buf_size = BUFSIZ, buf_left; @@ -1605,7 +1605,8 @@ char **env_array_from_file(const char *fname) int fd; /* - * If file name is a numeric value, then it is assumed to be a pipe. + * If file name is a numeric value, then it is assumed to be a + * file descriptor. */ fd = (int)strtol(fname, &p, 10); if ((*p != '\0') || (fd < 3) || (fd > sysconf(_SC_OPEN_MAX)) || @@ -1617,7 +1618,7 @@ char **env_array_from_file(const char *fname) } verbose("Getting environment variables from %s", fname); } else - verbose("Getting environment variables from pipe %d", fd); + verbose("Getting environment variables from fd %d", fd); /* * Read in the user's environment data. @@ -1647,25 +1648,18 @@ char **env_array_from_file(const char *fname) * and build the environment. */ env = env_array_create(); - line = xmalloc(ENV_BUFSIZE); value = xmalloc(ENV_BUFSIZE); - ptr = buf; - while (ptr) { - memset(line, 0, ENV_BUFSIZE); + for (ptr = buf; ; ptr = eptr+1) { eptr = strchr(ptr, separator); if ((ptr == eptr) || (eptr == NULL)) break; - strncpy(line, ptr,(eptr - ptr)); - ptr = eptr + 1; - if (_env_array_entry_splitter(line, name, sizeof(name), + if (_env_array_entry_splitter(ptr, name, sizeof(name), value, ENV_BUFSIZE) && - (!_discard_env(name, value)) && - (name[0] != ' ')) { + (!_discard_env(name, value))) { env_array_overwrite(&env, name, value); } } xfree(buf); - xfree(line); xfree(value); return env; diff --git a/src/sbatch/opt.c b/src/sbatch/opt.c index 88aa8b034554eea10c368627fa6cf8ecba4e67d2..f9c55805eb59bc7ba94daeda9725093e0d49278d 100644 --- a/src/sbatch/opt.c +++ b/src/sbatch/opt.c @@ -2803,7 +2803,7 @@ static void _usage(void) " [--network=type] [--mem-per-cpu=MB] [--qos=qos] [--gres=list]\n" " [--cpu_bind=...] [--mem_bind=...] [--reservation=name]\n" " [--switch=max-switches{@max-time-to-wait}]\n" -" [--export[=names]] [--export-file=file|pipe] executable [args...]\n"); +" [--export[=names]] [--export-file=file|fd] executable [args...]\n"); } static void _help(void) @@ -2822,7 +2822,7 @@ static void _help(void) " -D, --workdir=directory set working directory for batch script\n" " -e, --error=err file for batch script's standard error\n" " --export[=names] specify environment variables to export\n" -" --export-file=file|pipe specify environment variables file or pipe to export\n" +" --export-file=file|fd specify environment variables file or file descriptor to export\n" " --get-user-env load environment from local cluster\n" " --gid=group_id group ID to run job as (user root only)\n" " --gres=list required generic resources\n"