Salome HOME
projects
/
modules
/
kernel.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
USER or LOGNAME is not defined in a Docker container: on Linux get username with...
[modules/kernel.git]
/
src
/
Launcher
/
Launcher_Job.cxx
diff --git
a/src/Launcher/Launcher_Job.cxx
b/src/Launcher/Launcher_Job.cxx
index 0541c5cd0d7e0bd2fe208227673547a7d4cd94c7..b724958185a52363ba6549f74f733231b1e643f5 100644
(file)
--- a/
src/Launcher/Launcher_Job.cxx
+++ b/
src/Launcher/Launcher_Job.cxx
@@
-1,4
+1,4
@@
-// Copyright (C) 2009-20
17
CEA/DEN, EDF R&D, OPEN CASCADE
+// Copyright (C) 2009-20
22
CEA/DEN, EDF R&D, OPEN CASCADE
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
//
// This library is free software; you can redistribute it and/or
// modify it under the terms of the GNU Lesser General Public
@@
-22,6
+22,9
@@
//#define _DEBUG_
#include "Launcher_Job.hxx"
#include "Launcher.hxx"
//#define _DEBUG_
#include "Launcher_Job.hxx"
#include "Launcher.hxx"
+
+#include <Basics_DirUtils.hxx>
+
#include <boost/filesystem.hpp>
#ifdef WITH_LIBBATCH
#include <boost/filesystem.hpp>
#ifdef WITH_LIBBATCH
@@
-31,8
+34,10
@@
#include <sstream>
#ifdef WIN32
static const char SEPARATOR = '\\';
#include <sstream>
#ifdef WIN32
static const char SEPARATOR = '\\';
+#include <process.h>
#else
static const char SEPARATOR = '/';
#else
static const char SEPARATOR = '/';
+#include <pwd.h>
#endif
Launcher::Job::Job()
#endif
Launcher::Job::Job()
@@
-187,7
+192,12
@@
Launcher::Job::setResourceDefinition(const ParserResourcesType & resource_defini
if (resource_definition.UserName == "")
{
#ifndef WIN32
if (resource_definition.UserName == "")
{
#ifndef WIN32
- user_name = getenv("USER");
+ struct passwd *pwd = getpwuid(getuid());
+ if (pwd) {
+ user_name = std::string(pwd->pw_name);
+ }
+ if (user_name == "")
+ user_name = getenv("USER");
#else
user_name = getenv("USERNAME");
#endif
#else
user_name = getenv("USERNAME");
#endif
@@
-605,7
+615,8
@@
Launcher::Job::common_job_params()
params[Batch::NAME] = getJobName();
params[Batch::NBPROC] = _resource_required_params.nb_proc;
params[Batch::NAME] = getJobName();
params[Batch::NBPROC] = _resource_required_params.nb_proc;
- params[Batch::NBPROCPERNODE] = _resource_required_params.nb_proc_per_node;
+ if(_resource_required_params.nb_proc_per_node > 0)
+ params[Batch::NBPROCPERNODE] = _resource_required_params.nb_proc_per_node;
if(_resource_required_params.nb_node > 0)
params[Batch::NBNODE] = _resource_required_params.nb_node;
if(_resource_required_params.nb_node > 0)
params[Batch::NBNODE] = _resource_required_params.nb_node;
@@
-631,7
+642,11
@@
Launcher::Job::common_job_params()
{
std::string date_dir = std::string("/job_") + date;
std::ostringstream str_pid;
{
std::string date_dir = std::string("/job_") + date;
std::ostringstream str_pid;
+#ifdef WIN32
+ str_pid << _getpid();
+#else
str_pid << ::getpid();
str_pid << ::getpid();
+#endif
std::string job_dir = date_dir + "-" + str_pid.str();
_work_directory = _resource_definition.working_directory + job_dir;
std::string job_dir = date_dir + "-" + str_pid.str();
_work_directory = _resource_definition.working_directory + job_dir;
@@
-659,13
+674,10
@@
Launcher::Job::common_job_params()
params[Batch::LAUNCHER_FILE] = _launcher_file;
params[Batch::LAUNCHER_ARGS] = _launcher_args;
params[Batch::LAUNCHER_FILE] = _launcher_file;
params[Batch::LAUNCHER_ARGS] = _launcher_args;
- // If result_directory is not defined, we use HOME environ
ne
ment
+ // If result_directory is not defined, we use HOME environment
if (_result_directory == "")
if (_result_directory == "")
-#ifndef WIN32
- _result_directory = getenv("HOME");
-#else
- _result_directory = getenv("USERPROFILE");
-#endif
+ _result_directory = Kernel_Utils::HomePath();
+
// _in_files
std::list<std::string> in_files(_in_files);
in_files.push_back(_job_file);
// _in_files
std::list<std::string> in_files(_in_files);
in_files.push_back(_job_file);