mirror of
https://develop.openfoam.com/Development/openfoam.git
synced 2025-11-28 03:28:01 +00:00
Merge branch 'fix-systemcall' into 'develop'
replace system() call with vfork/exec combination (issue #185) Tested systemCall function object, dynamicCode, but should be rechecked with IB+openmpi @Prashant See merge request !55
This commit is contained in:
3
applications/test/cstring/Make/files
Normal file
3
applications/test/cstring/Make/files
Normal file
@ -0,0 +1,3 @@
|
||||
Test-cstring.C
|
||||
|
||||
EXE = $(FOAM_USER_APPBIN)/Test-cstring
|
||||
2
applications/test/cstring/Make/options
Normal file
2
applications/test/cstring/Make/options
Normal file
@ -0,0 +1,2 @@
|
||||
/* EXE_INC = -I$(LIB_SRC)/cfdTools/include */
|
||||
/* EXE_LIBS = -lfiniteVolume */
|
||||
99
applications/test/cstring/Test-cstring.C
Normal file
99
applications/test/cstring/Test-cstring.C
Normal file
@ -0,0 +1,99 @@
|
||||
/*---------------------------------------------------------------------------*\
|
||||
========= |
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2016 OpenCFD Ltd.
|
||||
\\/ M anipulation |
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
|
||||
OpenFOAM is free software: you can redistribute it and/or modify it
|
||||
under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
OpenFOAM is distributed in the hope that it will be useful, but WITHOUT
|
||||
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with OpenFOAM. If not, see <http://www.gnu.org/licenses/>.
|
||||
|
||||
Description
|
||||
Test some string functionality
|
||||
|
||||
\*---------------------------------------------------------------------------*/
|
||||
|
||||
#include "CStringList.H"
|
||||
#include "DynamicList.H"
|
||||
#include "IOstreams.H"
|
||||
#include "fileNameList.H"
|
||||
#include "stringList.H"
|
||||
#include "wordList.H"
|
||||
|
||||
using namespace Foam;
|
||||
|
||||
// * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * //
|
||||
|
||||
int print(int argc, char *argv[])
|
||||
{
|
||||
Info<< "argc=" << argc << endl;
|
||||
for (int i=0; i<argc; ++i)
|
||||
{
|
||||
Info<< " argv[" << i << "] = \"" << argv[i] << "\"" << endl;
|
||||
}
|
||||
return argc;
|
||||
}
|
||||
|
||||
int print(const CStringList& cstrLst)
|
||||
{
|
||||
return print(cstrLst.size(), cstrLst.strings());
|
||||
}
|
||||
|
||||
|
||||
// Main program:
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
DynamicList<string> dynlst;
|
||||
dynlst.reserve(16);
|
||||
|
||||
dynlst.append("string1 with content");
|
||||
dynlst.append("string2 other content");
|
||||
dynlst.append("string3 done");
|
||||
|
||||
{
|
||||
CStringList inC(dynlst);
|
||||
|
||||
Info<< "input: " << dynlst << endl;
|
||||
print(inC);
|
||||
}
|
||||
|
||||
Info<<"command-line with " << CStringList::count(argv) << " items"<< endl;
|
||||
|
||||
print(argc, argv);
|
||||
{
|
||||
dynlst.clear();
|
||||
for (int i=0; i<argc; ++i)
|
||||
{
|
||||
dynlst.append(argv[i]);
|
||||
}
|
||||
|
||||
Info<< "input: " << dynlst << endl;
|
||||
CStringList inC(dynlst);
|
||||
inC.reset(dynlst);
|
||||
|
||||
print(inC);
|
||||
Info<< "length: " << inC.length() << endl;
|
||||
std::cout.write(inC.data(), inC.length());
|
||||
}
|
||||
|
||||
|
||||
Info<< "\nEnd\n" << endl;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
// ************************************************************************* //
|
||||
@ -151,7 +151,7 @@ void Foam::helpType::displayDoc
|
||||
Info<< "Source file: " << classDirectory.c_str() << classFile << nl
|
||||
<< endl;
|
||||
|
||||
system(docBrowser);
|
||||
Foam::system(docBrowser);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@ -1309,7 +1309,7 @@ int main(int argc, char *argv[])
|
||||
+ "_"
|
||||
+ procFile.name()
|
||||
);
|
||||
if (system(cmd.c_str()) == -1)
|
||||
if (Foam::system(cmd.c_str()) == -1)
|
||||
{
|
||||
WarningInFunction
|
||||
<< "Could not execute command " << cmd << endl;
|
||||
|
||||
@ -3,7 +3,7 @@
|
||||
\\ / F ield | OpenFOAM: The Open Source CFD Toolbox
|
||||
\\ / O peration |
|
||||
\\ / A nd | Copyright (C) 2011-2016 OpenFOAM Foundation
|
||||
\\/ M anipulation |
|
||||
\\/ M anipulation | Copyright (C) 2016 OpenCFD Ltd.
|
||||
-------------------------------------------------------------------------------
|
||||
License
|
||||
This file is part of OpenFOAM.
|
||||
@ -191,9 +191,15 @@ void writeRays
|
||||
str << "l " << vertI-1 << ' ' << vertI << nl;
|
||||
}
|
||||
}
|
||||
string cmd("objToVTK " + fName + " " + fName.lessExt() + ".vtk");
|
||||
Pout<< "cmd:" << cmd << endl;
|
||||
system(cmd);
|
||||
str.flush();
|
||||
|
||||
DynamicList<string> cmd(3);
|
||||
cmd.append("objToVTK");
|
||||
cmd.append(fName);
|
||||
cmd.append(fName.lessExt() + ".vtk");
|
||||
|
||||
Pout<< "cmd: objToVTK " << fName.c_str() << endl;
|
||||
Foam::system(cmd);
|
||||
}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user