process-cpp-1.0.0+14.04.20140328/ 0000755 0000152 0177776 00000000000 12315242015 016341 5 ustar pbuser nogroup 0000000 0000000 process-cpp-1.0.0+14.04.20140328/include/ 0000755 0000152 0177776 00000000000 12315242015 017764 5 ustar pbuser nogroup 0000000 0000000 process-cpp-1.0.0+14.04.20140328/include/core/ 0000755 0000152 0177776 00000000000 12315242015 020714 5 ustar pbuser nogroup 0000000 0000000 process-cpp-1.0.0+14.04.20140328/include/core/testing/ 0000755 0000152 0177776 00000000000 12315242015 022371 5 ustar pbuser nogroup 0000000 0000000 process-cpp-1.0.0+14.04.20140328/include/core/testing/fork_and_run.h 0000644 0000152 0177776 00000012062 12315241606 025217 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2012-2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_TESTING_FORK_AND_RUN_H_
#define CORE_TESTING_FORK_AND_RUN_H_
#include
#include
#include
#include
namespace core
{
namespace testing
{
/**
* @brief The ForkAndRunResult enum models the different failure modes of fork_and_run.
*/
enum class ForkAndRunResult
{
empty = 0, ///< Special value indicating no bit being set.
client_failed = 1 << 0, ///< The client failed.
service_failed = 1 << 1 ///< The service failed.
};
CORE_POSIX_DLL_PUBLIC ForkAndRunResult operator|(ForkAndRunResult lhs, ForkAndRunResult rhs);
CORE_POSIX_DLL_PUBLIC ForkAndRunResult operator&(ForkAndRunResult lhs, ForkAndRunResult rhs);
/**
* @brief Forks two processes for both the service and the client.
*
* The function does the following:
* - Forks a process for the service and runs the respective closure.
* - Forks a process for the client and runs the respective closure.
* - After the client has finished, the service is signalled with sigterm.
*
* @throw std::system_error if an error occured during process interaction.
* @throw std::runtime_error for signalling all other error conditions.
* @param [in] service The service to be executed in a child process.
* @param [in] client The client to be executed in a child process.
* @return ForkAndRunResult indicating if either of service or client failed.
*/
CORE_POSIX_DLL_PUBLIC ForkAndRunResult fork_and_run(
const std::function& service,
const std::function& client);
}
}
/**
* Test definition macro which runs a TEST in a forked process.
* Note that you can only use EXPECT_*, not
* ASSERT_*!
*
* Usage:
* TESTP(test_suite, test_name, {
* test code ...
* EXPECT_* ...
* })
*/
#define TESTP(test_suite, test_name, CODE) \
TEST(test_suite, test_name) { \
auto test = [&]() { \
CODE \
return HasFailure() ? core::posix::exit::Status::failure \
: core::posix::exit::Status::success; \
}; \
auto child = core::posix::fork( \
test, \
core::posix::StandardStream::empty); \
auto result = child.wait_for(core::posix::wait::Flags::untraced); \
EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status); \
EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status); \
} \
/**
* Test definition macro which runs a TEST_F in a forked process.
* Note that you can only use EXPECT_*, not ASSERT_*!
*
* Usage:
* TESTP_F(FixtureName, TestName, {
* ... test code ...
* EXPECT_* ...
* })
*/
#define TESTP_F(test_fixture, test_name, CODE) \
TEST_F(test_fixture, test_name) { \
auto test = [&]() { \
CODE \
return HasFailure() ? core::posix::exit::Status::failure \
: core::posix::exit::Status::success; \
}; \
auto child = core::posix::fork( \
test, \
core::posix::StandardStream::empty); \
auto result = child.wait_for(core::posix::wait::Flags::untraced); \
EXPECT_EQ(core::posix::wait::Result::Status::exited, result.status); \
EXPECT_EQ(core::posix::exit::Status::success, result.detail.if_exited.status); \
} \
#endif // CORE_TESTING_FORK_AND_RUN_H_
process-cpp-1.0.0+14.04.20140328/include/core/testing/cross_process_sync.h 0000644 0000152 0177776 00000005553 12315241606 026502 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 this program. If not, see .
*
* Authored by: Thomas Voss
*/
#ifndef CORE_TESTING_CROSS_PROCESS_SYNC_H_
#define CORE_TESTING_CROSS_PROCESS_SYNC_H_
#include
#include
#include
#include
namespace core
{
namespace testing
{
/**
* @brief A cross-process synchronization primitive that supports simple wait-condition-like scenarios.
*/
class CORE_POSIX_DLL_PUBLIC CrossProcessSync
{
public:
struct Error
{
Error() = delete;
~Error() = delete;
/**
* @brief Thrown if any of the *_for functions times out.
*/
struct Timeout : public std::runtime_error
{
Timeout() : std::runtime_error("Timeout while waiting for event to happen.")
{
}
};
};
/**
* @brief Constructs a new sync element.
*/
CrossProcessSync();
/**
* @brief Copy c'tor, duping the underlying fds.
* @param rhs The instance to copy.
*/
CrossProcessSync(const CrossProcessSync& rhs);
/**
* @brief Closes the underlying fds.
*/
~CrossProcessSync() noexcept;
/**
* @brief operator =, dup's the underlying fds.
* @param rhs The instance to assign from.
* @return A mutable reference to this instance.
*/
CrossProcessSync& operator=(const CrossProcessSync& rhs);
/**
* @brief Try to signal the other side that we are ready for at most duration milliseconds.
* @throw Error::Timeout in case of a timeout.
* @throw std::system_error for problems with the underlying pipe.
*/
void try_signal_ready_for(const std::chrono::milliseconds& duration);
/**
* @brief Wait for the other sides to signal readiness for at most duration milliseconds.
* @return The number of ready signals that have been collected since creation.
* @throw Error::Timeout in case of a timeout.
* @throw std::system_error for problems with the underlying pipe.
*/
std::uint32_t wait_for_signal_ready_for(const std::chrono::milliseconds& duration);
private:
int fds[2]; ///< The cross-process pipe.
std::uint32_t counter; ///< Counts the number of times the sync has been signalled.
};
}
}
#endif // CORE_TESTING_CROSS_PROCESS_SYNC_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/ 0000755 0000152 0177776 00000000000 12315242015 022056 5 ustar pbuser nogroup 0000000 0000000 process-cpp-1.0.0+14.04.20140328/include/core/posix/signalable.h 0000644 0000152 0177776 00000003406 12315241606 024340 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_SIGNALABLE_H_
#define CORE_POSIX_SIGNALABLE_H_
#include
#include
#include
#include
namespace core
{
namespace posix
{
/**
* @brief The Signalable class abstracts the ability of an entity to be delivered a posix signal.
*/
class CORE_POSIX_DLL_PUBLIC Signalable
{
public:
/**
* @brief Sends a signal to this signalable object.
* @throws std::system_error in case of problems.
* @param [in] signal The signal to be sent to the process.
*/
virtual void send_signal_or_throw(Signal signal);
/**
* @brief Sends a signal to this signalable object.
* @param [in] signal The signal to be sent to the process.
* @param [out] e Set to contain an error if an issue arises.
*/
virtual void send_signal(Signal signal, std::error_code& e) noexcept(true);
protected:
CORE_POSIX_DLL_LOCAL explicit Signalable(pid_t pid);
private:
struct CORE_POSIX_DLL_LOCAL Private;
std::shared_ptr d;
};
}
}
#endif // CORE_POSIX_SIGNALABLE_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/this_process.h 0000644 0000152 0177776 00000010224 12315241606 024740 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_THIS_PROCESS_H_
#define CORE_POSIX_THIS_PROCESS_H_
#include
#include
#include
#include
#include
namespace core
{
namespace posix
{
class Process;
namespace this_process
{
namespace env
{
/**
* @brief for_each invokes a functor for every key-value pair in the environment.
* @param [in] functor Invoked for every key-value pair.
*/
CORE_POSIX_DLL_PUBLIC void for_each(
const std::function& functor) noexcept(true);
/**
* @brief get queries the value of an environment variable.
* @throw std::runtime_error if there is no variable with the given key defined in the env.
* @param [in] key Name of the variable to query the value for.
* @return Contents of the variable.
*/
CORE_POSIX_DLL_PUBLIC std::string get_or_throw(const std::string& key);
/**
* @brief get queries the value of an environment variable.
* @param [in] key Name of the variable to query the value for.
* @param [in] default_value Default value to return when key is not present in the environment.
* @return Contents of the variable or an empty string if the variable is not defined.
*/
CORE_POSIX_DLL_PUBLIC std::string get(
const std::string& key,
const std::string& default_value = std::string()) noexcept(true);
/**
* @brief unset_or_throw removes the variable with name key from the environment.
* @throw std::system_error in case of errors.
* @param [in] key Name of the variable to unset.
*/
CORE_POSIX_DLL_PUBLIC void unset_or_throw(const std::string& key);
/**
* @brief unset removes the variable with name key from the environment.
* @return false in case of errors, true otherwise.
* @param [in] key Name of the variable to unset.
* @param [out] se Receives error details if unset returns false.
*/
CORE_POSIX_DLL_PUBLIC bool unset(const std::string& key,
std::error_code& se) noexcept(true);
/**
* @brief set_or_throw will adjust the contents of the variable identified by key to the provided value.
* @throw std::system_error in case of errors.
* @param [in] key Name of the variable to set the value for.
* @param [in] value New contents of the variable.
*/
CORE_POSIX_DLL_PUBLIC void set_or_throw(const std::string& key,
const std::string& value);
/**
* @brief set will adjust the contents of the variable identified by key to the provided value.
* @return false in case of errors, true otherwise.
* @param [in] key Name of the variable to set the value for.
* @param [in] value New contents of the variable.
* @param [out] se Receives the details in case of errors.
*/
CORE_POSIX_DLL_PUBLIC bool set(const std::string &key,
const std::string &value,
std::error_code& se) noexcept(true);
}
/**
* @brief Returns a Process instance corresponding to this process.
*/
CORE_POSIX_DLL_PUBLIC Process instance() noexcept(true);
/**
* @brief Query the parent of the process.
* @return The parent of the process.
*/
CORE_POSIX_DLL_PUBLIC Process parent() noexcept(true);
/**
* @brief Access this process's stdin.
*/
CORE_POSIX_DLL_PUBLIC std::istream& cin() noexcept(true);
/**
* @brief Access this process's stdout.
*/
CORE_POSIX_DLL_PUBLIC std::ostream& cout() noexcept(true);
/**
* @brief Access this process's stderr.
*/
CORE_POSIX_DLL_PUBLIC std::ostream& cerr() noexcept(true);
}
}
}
#endif // CORE_POSIX_THIS_PROCESS_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/fork.h 0000644 0000152 0177776 00000003757 12315241606 023211 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_FORK_H_
#define CORE_POSIX_FORK_H_
#include
#include
#include
#include
namespace core
{
namespace posix
{
/**
* @brief fork forks a new process and executes the provided main function in the newly forked process.
* @throws std::system_error in case of errors.
* @param [in] main The main function of the newly forked process.
* @param [in] flags Specify which standard streams should be redirected to the parent process.
* @return An instance of ChildProcess in case of success.
*/
CORE_POSIX_DLL_PUBLIC ChildProcess fork(const std::function& main,
const StandardStream& flags);
/**
* @brief fork vforks a new process and executes the provided main function in the newly forked process.
* @throws std::system_error in case of errors.
* @param [in] main The main function of the newly forked process.
* @param [in] flags Specify which standard streams should be redirected to the parent process.
* @return An instance of ChildProcess in case of success.
*/
CORE_POSIX_DLL_PUBLIC ChildProcess vfork(const std::function& main,
const StandardStream& flags);
}
}
#endif // CORE_POSIX_FORK_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/exit.h 0000644 0000152 0177776 00000002026 12315241606 023205 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_EXIT_H_
#define CORE_POSIX_EXIT_H_
#include
namespace core
{
namespace posix
{
namespace exit
{
/**
* @brief The Status enum wrap's the posix exit status.
*/
enum class Status
{
success = EXIT_SUCCESS,
failure = EXIT_FAILURE
};
}
}
}
#endif // CORE_POSIX_EXIT_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/child_process.h 0000644 0000152 0177776 00000012251 12315241606 025056 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_CHILD_PROCESS_H_
#define CORE_POSIX_CHILD_PROCESS_H_
#include
#include
#include
#include
#include
#include
namespace core
{
namespace posix
{
/**
* @brief The Process class models a child process of this process.
*
* In addition to the functionality offered by the Process class, an instance
* of ChildProcess offers functionality to wait for status changes of the child
* process and to access the child process's standard streams if they have been
* redirected when forking or exec'ing.
*/
class CORE_POSIX_DLL_PUBLIC ChildProcess : public Process
{
public:
/**
* @brief The DeathObserver class observes child process' states and emits a signal when a monitored child has died.
*
* Please note that the name of this class is morbid for a reason: Listening
* for SIGCHLD is not enough to catch all dying children. Whenever a SIGCHLD is
* received, we have to wait for all the children of this process and reap all
* monitored ones. We are thus changing state and potentially race with other
* wait operations on children.
*
*/
class DeathObserver
{
public:
/**
* @brief Creates the unique instance of class DeathObserver.
* @throw std::logic_error if the given SignalTrap instance does not trap Signal::sig_chld.
* @throw std::runtime_error if there already is an instance of the death observer.
*/
static std::unique_ptr create_once_with_signal_trap(
std::shared_ptr trap);
DeathObserver(const DeathObserver&) = delete;
virtual ~DeathObserver() = default;
DeathObserver& operator=(const DeathObserver&) = delete;
bool operator==(const DeathObserver&) const = delete;
/**
* @brief add adds the specified child to the list of observed child processes.
* @param child The child to be observed.
* @return true iff the child has been added to the list of observed child processes.
*/
virtual bool add(const ChildProcess& child) = 0;
/**
* @brief has checks whether the specified child is observed.
* @param child The child to check for.
* @return true iff the specified child is observed for state changes.
*/
virtual bool has(const ChildProcess& child) const = 0;
/**
* @brief child_died is emitted whenever an observed child ceases to exist.
*/
virtual const core::Signal& child_died() const = 0;
/**
* @brief Checks and reaps all child processes registered with the observer instance.
*/
virtual void on_sig_child() = 0;
protected:
DeathObserver() = default;
};
/**
* @brief Creates an invalid ChildProcess.
* @return An invalid ChildProcess instance.
*/
static ChildProcess invalid();
~ChildProcess();
/**
* @brief Wait for the child process to change state.
* @param [in] flags Alters the behavior of the wait operation.
* @return Result of the wait operation, as well as information about the
* reasons for a child process's state change.
*/
wait::Result wait_for(const wait::Flags& flags);
/**
* @brief Access this process's stderr.
*/
std::istream& cerr();
/**
* @brief Access this process's stdin.
*/
std::ostream& cin();
/**
* @brief Access this process's stdout.
*/
std::istream& cout();
private:
friend ChildProcess fork(const std::function&, const StandardStream&);
friend ChildProcess vfork(const std::function&, const StandardStream&);
class CORE_POSIX_DLL_LOCAL Pipe
{
public:
static Pipe invalid();
Pipe();
Pipe(const Pipe& rhs);
~Pipe();
Pipe& operator=(const Pipe& rhs);
int read_fd() const;
void close_read_fd();
int write_fd() const;
void close_write_fd();
private:
Pipe(int fds[2]);
int fds[2];
};
CORE_POSIX_DLL_LOCAL ChildProcess(pid_t pid,
const Pipe& stdin,
const Pipe& stdout,
const Pipe& stderr);
struct CORE_POSIX_DLL_LOCAL Private;
std::shared_ptr d;
};
}
}
#endif // CORE_POSIX_CHILD_PROCESS_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/visibility.h 0000644 0000152 0177776 00000002023 12315241606 024420 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_VISIBILITY_H_
#define CORE_POSIX_VISIBILITY_H_
#if __GNUC__ >= 4
#define CORE_POSIX_DLL_PUBLIC __attribute__ ((visibility ("default")))
#define CORE_POSIX_DLL_LOCAL __attribute__ ((visibility ("hidden")))
#else
#define CORE_POSIX_DLL_PUBLIC
#define CORE_POSIX_DLL_LOCAL
#endif
#endif // CORE_POSIX_VISIBILITY_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/ 0000755 0000152 0177776 00000000000 12315242015 023215 5 ustar pbuser nogroup 0000000 0000000 process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/proc/ 0000755 0000152 0177776 00000000000 12315242015 024160 5 ustar pbuser nogroup 0000000 0000000 process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/proc/process/ 0000755 0000152 0177776 00000000000 12315242015 025636 5 ustar pbuser nogroup 0000000 0000000 process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/proc/process/stat.h 0000644 0000152 0177776 00000017362 12315241606 027000 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2012-2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_LINUX_PROC_PROCESS_STAT_H_
#define CORE_POSIX_LINUX_PROC_PROCESS_STAT_H_
#include
#include
#include
namespace core
{
namespace posix
{
class Process;
namespace linux
{
namespace proc
{
namespace process
{
/**
* @brief The Stat struct encapsulates status information about a process.
*/
struct CORE_POSIX_DLL_PUBLIC Stat
{
pid_t pid = 1; ///< The process ID
std::string executable; ///< The filename of the executable, in parentheses.
State state = State::undefined; ///< State of the process.
pid_t parent = -1; ///< The PID of the parent.
pid_t process_group = -1; ///< The process group ID of the process.
int session_id = -1; ///< The session ID of the process.
int tty_nr = -1; ///< The controlling terminal of the process.
int controlling_process_group = -1; ///< The ID of the foreground process group of the controlling terminal of the process.
unsigned int kernel_flags = 0; ///< The kernel flags word of the process.
long unsigned int minor_faults_count = 0; ///< The number of minor faults the process has made which have not required loading a memory page from disk.
long unsigned int minor_faults_count_by_children = 0; ///< The number of minor faults that the process's waited-for children have made.
long unsigned int major_faults_count = 0; ///< The number of major faults the process has made which have required loading a memory page from disk.
long unsigned int major_faults_count_by_children = 0; ///< The number of major faults that the process's waited-for children have made.
struct
{
long unsigned int user = 0; ///< Amount of time that this process has been scheduled in user mode, [clock ticks].
long unsigned int system = 0; ///< Amount of time that this process has been scheduled in kernel mode, [clock ticks].
long unsigned int user_for_children = 0; ///< Amount of time that this process's waited-for children have been scheduled in user mode, [clock ticks].
long unsigned int system_for_children = 0; ///< Amount of time that this process's waited-for children have been scheduled in kernel mode, [clock ticks].
} time;
/**
* (Explanation for Linux 2.6) For processes running a real-time scheduling
* policy (policy below; see sched_setscheduler(2)), this is the negated
* scheduling priority, minus one; that is, a number in the range -2 to
* -100, corresponding to real-time priorities 1 to 99. For processes running
* under a non-real-time scheduling policy, this is the raw nice value
* (setpriority(2)) as represented in the kernel. The kernel stores nice
* values as numbers in the range 0 (high) to 39 (low), corresponding to
* the user-visible nice range of -20 to 19.
*
*Before Linux 2.6, this was a scaled value based on the scheduler
*weighting given to this process.
*/
long int priority = 0;
long int nice = 0; ///< The nice value (see setpriority(2)), a value in the range 19 (low priority) to -20 (high priority).
long int thread_count = 0; ///< Number of threads in this process (since Linux 2.6).
long int time_before_next_sig_alarm = 0; ///< The time in jiffies before the next SIGALRM is sent to the process due to an interval timer. Since kernel 2.6.17, this field is no longer maintained, and is hard coded as 0.
long int start_time = 0; ///< The time the process started after system boot. In kernels before Linux 2.6, this value was expressed in jiffies. Since Linux 2.6, the value is expressed in clock ticks (divide by sysconf(_SC_CLK_TCK)).
struct
{
long unsigned int virt = 0; ///< Virtual memory size in bytes.
long unsigned int resident_set = 0; ///< Resident Set Size: number of pages the process has in real memory. This is just the pages which count toward text, data, or stack space. This does not include pages which have not been demand-loaded in, or which are swapped out.
long unsigned int resident_set_limit = 0; ///< Current soft limit in bytes on the rss of the process; see the description of RLIMIT_RSS in getrlimit(2).
} size;
struct
{
long unsigned int start_code = 0; ///< The address above which program text can run.
long unsigned int end_code = 0; ///< The address below which program text can run.
long unsigned int start_stack = 0; ///< The address of the start (i.e., bottom) of the stack.
long unsigned int stack_pointer = 0; ///< The current value of ESP (stack pointer), as found in the kernel stack page for the process.
long unsigned int instruction_pointer = 0; ///< The current EIP (instruction pointer).
} addresses;
struct
{
long unsigned int pending = 0; ///< The bitmap of pending signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead.
long unsigned int blocked = 0; ///< The bitmap of blocked signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead.
long unsigned int ignored = 0; ///< The bitmap of ignored signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead.
long unsigned int caught = 0; ///< The bitmap of caught signals, displayed as a decimal number. Obsolete, because it does not provide information on real-time signals; use /proc/[pid]/status instead.
} signals;
long unsigned int channel = 0; ///< This is the "channel" in which the process is waiting. It is the address of a system call, and can be looked up in a namelist if you need a textual name. (If you have an up-to-date /etc/psdatabase, then try ps -l to see the WCHAN field in action.)
long unsigned int swap_count = 0; ///< Number of pages swapped (not maintained).
long unsigned int swap_count_children = 0; ///< Cumulative nswap for child processes (not maintained).
int exit_signal = -1; ///< Signal to be sent to parent when we die.
int cpu_count = -1; ///< CPU number last executed on.
unsigned int realtime_priority = 0; ///< Real-time scheduling priority, a number in the range 1 to 99 for processes scheduled under a real-time policy, or 0, for non-real-time processes (see sched_setscheduler(2)).
unsigned int scheduling_policy = 0; ///< Scheduling policy (see sched_setscheduler(2)). Decode using the SCHED_* constants in linux/sched.h.
long long unsigned int aggregated_block_io_delays = 0; ///< Aggregated block I/O delays, measured in clock ticks (centiseconds).
long unsigned int guest_time = 0; ///< Guest time of the process (time spent running a virtual CPU for a guest operating system), measured in clock ticks.
long unsigned int guest_time_children = 0; ///< Guest time of the process's children, measured in clock ticks.
};
CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, Stat& stat);
}
}
}
}
}
#endif // CORE_POSIX_LINUX_PROC_PROCESS_STAT_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/proc/process/oom_score_adj.h 0000644 0000152 0177776 00000012176 12315241606 030626 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2012-2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_ADJ_H_
#define CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_ADJ_H_
#include
namespace core
{
namespace posix
{
class Process;
namespace linux
{
namespace proc
{
namespace process
{
/**
* This file can be used to adjust the badness heuristic used to select which
* process gets killed in out-of-memory conditions.
*
* The badness heuristic assigns a value to each candidate task ranging from 0
* (never kill) to 1000 (always kill) to determine which process is targeted.
* The units are roughly a proportion along that range of allowed memory the
* process may allocate from, based on an estimation of its current memory and
* swap use. For example, if a task is using all allowed memory, its badness
* score will be 1000. If it is using half of its allowed memory, its score
* will be 500.
*
* There is an additional factor included in the badness score: root processes are
* given 3% extra memory over other tasks.
*
* The amount of "allowed" memory depends on the context in which the
* OOM-killer was called. If it is due to the memory assigned to the allocating
* task's cpuset being exhausted, the allowed memory represents the set of mems
* assigned to that cpuset (see cpuset(7)). If it is due to a mempolicy's node(s)
* being exhausted, the allowed memory represents the set of mempolicy nodes. If
* it is due to a memory limit (or swap limit) being reached, the allowed memory
* is that configured limit. Finally, if it is due to the entire system being out
* of memory, the allowed memory represents all allocatable resources.
*
* The value of oom_score_adj is added to the badness score before it is used
* to determine which task to kill. Acceptable values range from -1000
* (OOM_SCORE_ADJ_MIN) to +1000 (OOM_SCORE_ADJ_MAX). This allows user space to
* control the preference for OOM-killing, ranging from always preferring a
* certain task or completely disabling it from OOM- killing. The lowest possible
* value, -1000, is equivalent to disabling OOM-killing entirely for that task,
* since it will always report a badness score of 0.
*
* Consequently, it is very simple for user space to define the amount of
* memory to consider for each task. Setting a oom_score_adj value of +500, for
* example, is roughly equivalent to allowing the remainder of tasks sharing
* the same system, cpuset, mempolicy, or memory controller resources to use at
* least 50% more memory. A value of -500, on the other hand, would be roughly
* equivalent to discounting 50% of the task's allowed memory from being
* considered as scoring against the task.
*
* For backward compatibility with previous kernels, /proc/[pid]/oom_adj can
* still be used to tune the badness score. Its value is scaled linearly with
* oom_score_adj.
*
* Writing to /proc/[pid]/oom_score_adj or /proc/[pid]/oom_adj will change the
* other with its scaled value.
*/
struct CORE_POSIX_DLL_PUBLIC OomScoreAdj
{
/**
* @brief Returns the minimum valid value.
* @return The minimum valid value that the Oom Score Adj can be set to.
*/
static int min_value();
/**
* @brief Returns the maximum valid value.
* @return The maximum valid value that the Oom Score Adj can be set to.
*/
static int max_value();
/**
* @brief is_valid checks whether the contained value is within the predefined bounds.
* @return true iff min_value() <= value <= max_value().
*/
inline bool is_valid() const
{
return (min_value() <= value) && (value <= max_value());
}
/**
* @brief Current value.
*/
int value;
};
/**
* @brief Read the OomScoreAdj value for a process instance.
* @throw std::runtime_error in case of errors.
* @param [in] process The process to read the score for.
* @param [out] score_adj The destination to store the value in.
*/
CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, OomScoreAdj& score_adj);
/**
* @brief Write the OomScoreAdj value for a process instance.
* @throw std::runtime_error in case of errors and std::logic_error if score_adj.is_valid() returns false.
* @param [in] process The process to write the score for.
* @param [in] score_adj The new value to store.
*/
CORE_POSIX_DLL_PUBLIC const posix::Process& operator<<(const posix::Process& process,
const OomScoreAdj& score_adj);
}
}
}
}
}
#endif // CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_ADJ_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/proc/process/state.h 0000644 0000152 0177776 00000002234 12315241606 027135 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2012-2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_LINUX_PROC_PROCESS_STATE_H_
#define CORE_POSIX_LINUX_PROC_PROCESS_STATE_H_
#include
#include
namespace core
{
namespace posix
{
namespace linux
{
namespace proc
{
namespace process
{
enum class State
{
undefined = -1,
running = 'R',
sleeping = 'S',
disk_sleep = 'D',
zombie = 'Z',
traced_or_stopped = 'T',
paging = 'W'
};
}
}
}
}
}
#endif // CORE_POSIX_LINUX_PROC_PROCESS_STATE_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/proc/process/oom_adj.h 0000644 0000152 0177776 00000006600 12315241606 027426 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2012-2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_LINUX_PROC_PROCESS_OOM_ADJ_H_
#define CORE_POSIX_LINUX_PROC_PROCESS_OOM_ADJ_H_
#include
namespace core
{
namespace posix
{
class Process;
namespace linux
{
namespace proc
{
namespace process
{
/**
* This file can be used to adjust the score used to select which process
* should be killed in an out-of-memory (OOM) situation. The kernel uses this
* value for a bit-shift operation of the process's oom_score value: valid
* values are in the range -16 to +15, plus the special value -17, which disables
* OOM-killing altogether for this process. A positive score increases the
* likelihood of this process being killed by the OOM-killer; a negative score
* decreases the likelihood.
*
* The default value for this file is 0; a new process inherits its parent's
* oom_adj setting. A process must be privileged (CAP_SYS_RESOURCE) to update
* this file.
*
* Since Linux 2.6.36, use of this file is deprecated in favor of
* /proc/[pid]/oom_score_adj.
*/
struct CORE_POSIX_DLL_PUBLIC OomAdj
{
/**
* @brief Returns the value that makes a process "invisible" to the oom killer.
* @return Returns the value that makes a process "invisible" to the oom killer.
*/
static int disable_value();
/**
* @brief Returns the minimum valid value.
* @return The minimum valid value that the OomAdj can be set to.
*/
static int min_value();
/**
* @brief Returns the maximum valid value.
* @return The maximum valid value that the OomAdj can be set to.
*/
static int max_value();
/**
* @brief is_valid checks whether the contained value is within the predefined bounds.
* @return true iff min_value() <= value <= max_value().
*/
inline bool is_valid() const
{
return (disable_value() <= value) && (value <= max_value());
}
/**
* @brief Current value.
*/
int value;
};
/**
* \brief Read the OomAdj value for a process instance.
* \throws std::runtime_error in case of errors.
* \param [in] process The process to read the score for.
* \param [out] adj The destination to store the value in.
*/
CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, OomAdj& adj);
/**
* \brief Write the OomAdj value for a process instance.
* \throw std::runtime_error in case of errors and std::logic_error if score_adj.is_valid() returns false.
* \param [in] process The process to write the score for.
* \param [in] adj The new value to store.
*/
CORE_POSIX_DLL_PUBLIC const posix::Process& operator<<(const posix::Process& process,
const OomAdj& adj);
}
}
}
}
}
#endif // CORE_POSIX_LINUX_PROC_PROCESS_OOM_ADJ_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/proc/process/oom_score.h 0000644 0000152 0177776 00000004401 12315241606 030000 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2012-2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_
#define CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_
#include
namespace core
{
namespace posix
{
class Process;
namespace linux
{
namespace proc
{
namespace process
{
/**
* This file displays the current score that the kernel gives to this process
* for the purpose of selecting a process for the OOM-killer. A higher score
* means that the process is more likely to be selected by the OOM-killer. The
* basis for this score is the amount of memory used by the process, with
* increases (+) or decreases (-) for factors including:
*
* - whether the process creates a lot of children using fork(2) (+);
* - whether the process has been running a long time, or has used a lot of CPU time (-);
* - whether the process has a low nice value (i.e., > 0) (+);
* - whether the process is privileged (-); and
* - whether the process is making direct hardware access (-).
*
* The oom_score also reflects the adjustment specified by the oom_score_adj or
* oom_adj setting for the process.
*/
struct CORE_POSIX_DLL_PUBLIC OomScore
{
int value = 0; ///< Current OomScore as calculated by the kernel.
};
/**
* \brief Read the OomScore for a process instance.
* \throws std::runtime_error in case of errors.
* \param [in] process The process to read the score for.
* \param [out] score The destination to store the value in.
*/
CORE_POSIX_DLL_PUBLIC const posix::Process& operator>>(const posix::Process& process, OomScore& score);
}
}
}
}
}
#endif // CORE_POSIX_LINUX_PROC_PROCESS_OOM_SCORE_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/signal.h 0000644 0000152 0177776 00000005627 12315241606 023523 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_SIGNAL_H_
#define CORE_POSIX_SIGNAL_H_
#include
#include
#include
#include
#include
namespace core
{
namespace posix
{
/**
* @brief The Signal enum collects the most common POSIX signals.
*/
enum class Signal
{
unknown = 0,
sig_hup = SIGHUP,
sig_int = SIGINT,
sig_quit = SIGQUIT,
sig_ill = SIGILL,
sig_abrt = SIGABRT,
sig_fpe = SIGFPE,
sig_kill = SIGKILL,
sig_segv = SIGSEGV,
sig_pipe = SIGPIPE,
sig_alrm = SIGALRM,
sig_term = SIGTERM,
sig_usr1 = SIGUSR1,
sig_usr2 = SIGUSR2,
sig_chld = SIGCHLD,
sig_cont = SIGCONT,
sig_stop = SIGSTOP,
sig_tstp = SIGTSTP,
sig_ttin = SIGTTIN,
sig_ttou = SIGTTOU
};
/**
* @brief The SignalTrap class encapsulates functionality to trap and handle signals.
*/
class CORE_POSIX_DLL_PUBLIC SignalTrap
{
public:
SignalTrap(const SignalTrap&) = delete;
virtual ~SignalTrap() = default;
SignalTrap& operator=(const SignalTrap&) = delete;
bool operator==(const SignalTrap&) const = delete;
/**
* @brief Returns true if the given signal is trapped by this instance.
*/
virtual bool has(Signal signal) = 0;
/**
* @brief Starts observation of incoming signals, relaying them via
* signal_raised(). The call blocks until stop is called.
*/
virtual void run() = 0;
/**
* @brief Stops execution of the signal trap.
*/
virtual void stop() = 0;
/**
* @brief Emitted whenever a trapped signal is raised by the operating system.
*/
virtual core::Signal& signal_raised() = 0;
protected:
SignalTrap() = default;
};
/**
* @brief Traps the specified signals for the entire process.
*/
CORE_POSIX_DLL_PUBLIC
std::shared_ptr trap_signals_for_process(
std::initializer_list blocked_signals);
/**
* @brief Traps the specified signals for the current thread, and inherits
* the respective signal mask to all child-threads.
*/
CORE_POSIX_DLL_PUBLIC
std::shared_ptr trap_signals_for_all_subsequent_threads(
std::initializer_list blocked_signals);
}
}
#endif
process-cpp-1.0.0+14.04.20140328/include/core/posix/process.h 0000644 0000152 0177776 00000005155 12315241606 023720 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_PROCESS_H_
#define CORE_POSIX_PROCESS_H_
#include
#include
#include
#include
#include
#include
#include
namespace core
{
namespace posix
{
enum class Signal;
class Self;
class WaitFlags;
/**
* @brief The Process class models a process and possible operations on it.
*
* The process class is implicitly shared.
*/
class CORE_POSIX_DLL_PUBLIC Process : public Signalable
{
public:
/**
* @brief Creates a process instance wrapping an existing process.
* @throw Throw std::system_error if pid is invalid, i.e., pid < 0.
* @param pid The process identifier of the existing process.
*/
explicit Process(pid_t pid);
/**
* @brief Returns an invalid instance for testing purposes.
* @return An invalid instance.
*/
static Process invalid();
/**
* @brief Frees resources associated with the process.
*/
virtual ~Process() noexcept;
/**
* @brief Query the pid of the process.
* @return The pid of the process.
*/
virtual pid_t pid() const;
/**
* @brief Queries the id of the process group this process belongs to.
* @throw std::system_error in case of errors.
* @return The id of the process group this process belongs to.
*/
virtual ProcessGroup process_group_or_throw() const;
/**
* @brief Queries the id of the process group this process belongs to.
*
* @return A tuple with the first element being the id of the process group
* this process belongs to and the second element a boolean flag indicating
* an error if true.
*/
virtual ProcessGroup process_group(std::error_code& se) const noexcept(true);
private:
struct CORE_POSIX_DLL_LOCAL Private;
std::shared_ptr d;
};
}
}
#endif // CORE_POSIX_PROCESS_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/wait.h 0000644 0000152 0177776 00000005637 12315241606 023213 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_WAIT_H_
#define CORE_POSIX_WAIT_H_
#include
#include
#include
#include
#include
#include
namespace core
{
namespace posix
{
namespace wait
{
/**
* @brief Flags enumerates different behavior when waiting for a child process to change state.
*/
enum class Flags : std::uint8_t
{
continued = WCONTINUED, ///< Also wait for a child to continue after having been stopped.
untraced = WUNTRACED, ///< Also wait for state changes in untraced children.
no_hang = WNOHANG ///< Do not block if a child process hasn't changed state.
};
CORE_POSIX_DLL_PUBLIC Flags operator|(Flags l, Flags r);
/**
* @brief The Result struct encapsulates the result of waiting for a process state change.
*/
struct CORE_POSIX_DLL_PUBLIC Result
{
/**
* @brief The status of the process/wait operation.
*/
enum class Status
{
undefined, ///< Marks an undefined state.
no_state_change, ///< No state change occured.
exited, ///< The process exited normally.
signaled, ///< The process was signalled and terminated.
stopped, ///< The process was signalled and stopped.
continued ///< The process resumed operation.
} status = Status::undefined;
/**
* @brief Union of result-specific details.
*/
union
{
/**
* Contains the exit status of the process if status == Status::exited.
*/
struct
{
exit::Status status; ///< Exit status of the process.
} if_exited;
/**
* Contains the signal that caused the process to terminate if status == Status::signaled.
*/
struct
{
Signal signal; ///< Signal that caused the process to terminate.
bool core_dumped; ///< true if the process termination resulted in a core dump.
} if_signaled;
/**
* Contains the signal that caused the process to terminate if status == Status::stopped.
*/
struct
{
Signal signal; ///< Signal that caused the process to terminate.
} if_stopped;
} detail;
};
}
}
}
#endif // CORE_POSIX_WAIT_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/process_group.h 0000644 0000152 0177776 00000003403 12315241606 025126 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_PROCESS_GROUP_H_
#define CORE_POSIX_PROCESS_GROUP_H_
#include
#include
#include
namespace core
{
namespace posix
{
class Process;
/**
* @brief The ProcessGroup class models a signalable group of process.
*
* Summary from http://en.wikipedia.org/wiki/Process_group:
*
* In POSIX-conformant operating systems, a process group denotes a collection
* of one or more processes. Process groups are used to control the distribution
* of signals. A signal directed to a process group is delivered individually to
* all of the processes that are members of the group.
*/
class CORE_POSIX_DLL_PUBLIC ProcessGroup : public Signalable
{
public:
/**
* @brief Accesses the id of this process group.
* @return The id of this process group.
*/
virtual pid_t id() const;
protected:
friend class Process;
CORE_POSIX_DLL_LOCAL ProcessGroup(pid_t id);
private:
struct CORE_POSIX_DLL_LOCAL Private;
std::shared_ptr d;
};
}
}
#endif // CORE_POSIX_PROCESS_GROUP_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/standard_stream.h 0000644 0000152 0177776 00000002411 12315241606 025405 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_STANDARD_STREAM_H_
#define CORE_POSIX_STANDARD_STREAM_H_
#include
#include
namespace core
{
namespace posix
{
/**
* @brief The StandardStream enum wraps the POSIX standard streams.
*/
enum class StandardStream : std::uint8_t
{
empty = 0,
stdin = 1 << 0,
stdout = 1 << 1,
stderr = 1 << 2
};
CORE_POSIX_DLL_PUBLIC StandardStream operator|(StandardStream l, StandardStream r);
CORE_POSIX_DLL_PUBLIC StandardStream operator&(StandardStream l, StandardStream r);
}
}
#endif // CORE_POSIX_STANDARD_STREAM_H_
process-cpp-1.0.0+14.04.20140328/include/core/posix/exec.h 0000644 0000152 0177776 00000003221 12315241606 023156 0 ustar pbuser nogroup 0000000 0000000 /*
* Copyright © 2013 Canonical Ltd.
*
* This program is free software: you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License version 3,
* as published by the Free Software Foundation.
*
* This program 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 Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public License
* along with this program. If not, see .
*
* Authored by: Thomas Voß
*/
#ifndef CORE_POSIX_EXEC_H_
#define CORE_POSIX_EXEC_H_
#include
#include
#include
#include