Base Framework
testsuite/Process.cpp
/***************************************************************************
The Base Framework
A framework for developing platform independent applications
See COPYRIGHT.txt for details.
This framework 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.
For the licensing terms refer to the file 'LICENSE'.
***************************************************************************/
#include <base/Application.h>
#include <base/concurrency/Process.h>
#include <base/TypeInfo.h>
#include <base/security/User.h>
using namespace com::azure::dev::base;
class ProcessApplication : public Application {
private:
static const unsigned int MAJOR_VERSION = 1;
static const unsigned int MINOR_VERSION = 0;
public:
ProcessApplication()
: Application("Process")
{
}
void dumpLimit(
const Literal& literal,
resource,
);
resource,
);
fout << indent(2) << literal << " (soft): ";
if (softLimit == -1) {
fout << "INFINITE";
} else {
fout << softLimit;
}
fout << ENDL;
fout << indent(2) << literal << " (hard): ";
if (hardLimit == -1) {
fout << "INFINITE";
} else {
fout << hardLimit;
}
fout << ENDL;
}
void main()
{
fout << getFormalName() << " version "
<< MAJOR_VERSION << '.' << MINOR_VERSION << EOL
<< "The Base Framework (Test Suite)" << EOL
<< ENDL;
fout << "Is administrator: " << User::getCurrentUser().isAdmin() << ENDL;
fout << "Current user: " << User::getCurrentUser().getName() << ENDL;
fout << "Current process: " << Process::getProcess().getId() << ENDL;
fout << "Parent process: " << Process::getParentProcess().getId() << ENDL;
fout << "Name of process: ";
try {
} catch (NotSupported&) {
fout << "unknown";
}
fout << ENDL;
fout << "Is parent process alive: ";
try {
fout << "unknown";
}
fout << ENDL;
fout << "Priority of process: "
fout << "Priority of parent process: "
fout << "Number of configured processors: "
fout << "Number of online processors: "
fout << ENDL;
fout << "Resource limits: " << ENDL;
dumpLimit(MESSAGE("Core file size"), OperatingSystem::RESOURCE_CORE);
dumpLimit(MESSAGE("CPU time"), OperatingSystem::RESOURCE_CPU);
dumpLimit(MESSAGE("Data segment size"), OperatingSystem::RESOURCE_DATA);
dumpLimit(MESSAGE("File size"), OperatingSystem::RESOURCE_FILE_SIZE);
dumpLimit(MESSAGE("Number of open files"), OperatingSystem::RESOURCE_OPEN_FILES);
dumpLimit(MESSAGE("Stack size"), OperatingSystem::RESOURCE_STACK);
dumpLimit(MESSAGE("Address space"), OperatingSystem::RESOURCE_ADDRESS_SPACE);
// wait
// terminate
// Process::execute(self img);
}
};
APPLICATION_STUB(ProcessApplication);
Process::getProcess
static Process getProcess() noexcept
OperatingSystem::RESOURCE_OPEN_FILES
@ RESOURCE_OPEN_FILES
Definition: OperatingSystem.h:147
Process::getName
String getName() const
Process::getPriority
static int getPriority()
User::getName
String getName(bool fallback=true) const
OperatingSystem::RESOURCE_CPU
@ RESOURCE_CPU
Definition: OperatingSystem.h:144
Process::getId
unsigned long getId() noexcept
Definition: Process.h:249
OperatingSystem::Resource
Resource
Definition: OperatingSystem.h:142
Literal
A string literal.
Definition: Literal.h:28
Process::getParentProcess
static Process getParentProcess() noexcept
OperatingSystem::RESOURCE_STACK
@ RESOURCE_STACK
Definition: OperatingSystem.h:148
OperatingSystem::RESOURCE_DATA
@ RESOURCE_DATA
Definition: OperatingSystem.h:145
User::isAdmin
bool isAdmin() const
OperatingSystem::HARD_LIMIT
@ HARD_LIMIT
Definition: OperatingSystem.h:154
Process::getNumberOfConfiguredProcessors
static unsigned long getNumberOfConfiguredProcessors() noexcept
Definition: Process.h:145
Process::ProcessException
Exception raised by Process.
Definition: Process.h:88
Application
Application.
Definition: Application.h:53
Process::getNumberOfOnlineProcessors
static unsigned long getNumberOfOnlineProcessors() noexcept
Definition: Process.h:158
OperatingSystem::getResourceLimit
static int64 getResourceLimit(Resource resource, LimitType type=SOFT_LIMIT) noexcept
User::getCurrentUser
static User getCurrentUser()
OperatingSystem::RESOURCE_ADDRESS_SPACE
@ RESOURCE_ADDRESS_SPACE
Definition: OperatingSystem.h:149
OperatingSystem::RESOURCE_CORE
@ RESOURCE_CORE
Definition: OperatingSystem.h:143
OperatingSystem::SOFT_LIMIT
@ SOFT_LIMIT
Definition: OperatingSystem.h:155
OperatingSystem::RESOURCE_FILE_SIZE
@ RESOURCE_FILE_SIZE
Definition: OperatingSystem.h:146
Process::isAlive
bool isAlive() const
NotSupported
Not supported exception.
Definition: NotSupported.h:30