process-cpp-1.0.0+14.04.20140328/0000755000015201777760000000000012315242015016341 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/include/0000755000015201777760000000000012315242015017764 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/include/core/0000755000015201777760000000000012315242015020714 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/include/core/testing/0000755000015201777760000000000012315242015022371 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/include/core/testing/fork_and_run.h0000644000015201777760000001206212315241606025217 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000555312315241606026502 0ustar pbusernogroup00000000000000/* * 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/0000755000015201777760000000000012315242015022056 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/include/core/posix/signalable.h0000644000015201777760000000340612315241606024340 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000001022412315241606024740 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000375712315241606023211 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000202612315241606023205 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000001225112315241606025056 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000202312315241606024420 0ustar pbusernogroup00000000000000/* * 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/0000755000015201777760000000000012315242015023215 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/proc/0000755000015201777760000000000012315242015024160 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/proc/process/0000755000015201777760000000000012315242015025636 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/include/core/posix/linux/proc/process/stat.h0000644000015201777760000001736212315241606027000 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000001217612315241606030626 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000223412315241606027135 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000660012315241606027426 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000440112315241606030000 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000562712315241606023523 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000515512315241606023720 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000563712315241606023213 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000340312315241606025126 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000241112315241606025405 0ustar pbusernogroup00000000000000/* * 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.h0000644000015201777760000000322112315241606023156 0ustar pbusernogroup00000000000000/* * 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 #include #include namespace core { namespace posix { enum class RedirectFlags; /** * @brief exec execve's the executable with the provided arguments and environment. * @throws std::system_error in case of errors. * @param fn The executable to run. * @param argv Vector of command line arguments * @param env Environment that the new process should run under * @param flags Specifies which standard streams should be redirected. * @return An instance of ChildProcess corresponding to the newly exec'd process. */ CORE_POSIX_DLL_PUBLIC ChildProcess exec(const std::string& fn, const std::vector& argv, const std::map& env, const StandardStream& flags); } } #endif // CORE_POSIX_EXEC_H_ process-cpp-1.0.0+14.04.20140328/include/CMakeLists.txt0000644000015201777760000000134012315241606022527 0ustar pbusernogroup00000000000000# 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 install( DIRECTORY core DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/ ) process-cpp-1.0.0+14.04.20140328/cmake/0000755000015201777760000000000012315242015017421 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/cmake/FindGtest.cmake0000644000015201777760000000337212315241606022324 0ustar pbusernogroup00000000000000include(ExternalProject) include(FindPackageHandleStandardArgs) #gtest set(GTEST_INSTALL_DIR /usr/src/gmock/gtest/include) find_path(GTEST_INCLUDE_DIR gtest/gtest.h HINTS ${GTEST_INSTALL_DIR}) #gmock find_path(GMOCK_INSTALL_DIR gmock/CMakeLists.txt HINTS /usr/src) if(${GMOCK_INSTALL_DIR} STREQUAL "GMOCK_INSTALL_DIR-NOTFOUND") message(FATAL_ERROR "google-mock package not found") endif() set(GMOCK_INSTALL_DIR ${GMOCK_INSTALL_DIR}/gmock) find_path(GMOCK_INCLUDE_DIR gmock/gmock.h) set(GMOCK_PREFIX gmock) set(GMOCK_BINARY_DIR ${CMAKE_BINARY_DIR}/${GMOCK_PREFIX}/libs) set(GTEST_BINARY_DIR ${GMOCK_BINARY_DIR}/gtest) set(GTEST_CMAKE_ARGS "") if (${MIR_IS_CROSS_COMPILING}) set(GTEST_CMAKE_ARGS -DCMAKE_TOOLCHAIN_FILE=${CMAKE_MODULE_PATH}/LinuxCrossCompile.cmake) endif() ExternalProject_Add( GMock #where to build in source tree PREFIX ${GMOCK_PREFIX} #where the source is external to the project SOURCE_DIR ${GMOCK_INSTALL_DIR} #forward the compilers to the subproject so cross-arch builds work CMAKE_ARGS ${GTEST_CMAKE_ARGS} BINARY_DIR ${GMOCK_BINARY_DIR} #we don't need to install, so skip INSTALL_COMMAND "" ) set(GMOCK_LIBRARY ${GMOCK_BINARY_DIR}/libgmock.a) set(GMOCK_MAIN_LIBRARY ${GMOCK_BINARY_DIR}/libgmock_main.a) set(GMOCK_BOTH_LIBRARIES ${GMOCK_LIBRARY} ${GMOCK_MAIN_LIBRARY}) set(GTEST_LIBRARY ${GTEST_BINARY_DIR}/libgtest.a) set(GTEST_MAIN_LIBRARY ${GTEST_BINARY_DIR}/libgtest_main.a) set(GTEST_BOTH_LIBRARIES ${GTEST_LIBRARY} ${GTEST_MAIN_LIBRARY}) set(GTEST_ALL_LIBRARIES ${GTEST_BOTH_LIBRARIES} ${GMOCK_BOTH_LIBRARIES}) find_package_handle_standard_args(GTest DEFAULT_MSG GMOCK_INCLUDE_DIR GTEST_INCLUDE_DIR) process-cpp-1.0.0+14.04.20140328/tests/0000755000015201777760000000000012315242015017503 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/tests/fork_and_run_test.cpp0000644000015201777760000001254312315241606023727 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include namespace { struct TestingMacrosFixture : public ::testing::Test { TestingMacrosFixture() = default; }; ::testing::AssertionResult ClientFailed(core::testing::ForkAndRunResult result) { return (result & core::testing::ForkAndRunResult::client_failed) == core::testing::ForkAndRunResult::empty ? ::testing::AssertionFailure() : ::testing::AssertionSuccess(); } ::testing::AssertionResult ServiceFailed(core::testing::ForkAndRunResult result) { return (result & core::testing::ForkAndRunResult::service_failed) == core::testing::ForkAndRunResult::empty ? ::testing::AssertionFailure() : ::testing::AssertionSuccess(); } struct SigTermCatcher { static void sig_term_handler(int) { std::cout << "Received sigterm." << std::endl; } SigTermCatcher() { signal(static_cast(core::posix::Signal::sig_term), sig_term_handler); } } sig_term_catcher; } TEST(ForkAndRun, succeeding_client_and_service_result_in_correct_return_value) { auto service = [](){ return core::posix::exit::Status::success; }; auto client = [](){ return core::posix::exit::Status::success; }; auto result = core::testing::fork_and_run(service, client); ASSERT_FALSE(ClientFailed(result)); ASSERT_FALSE(ServiceFailed(result)); } TEST(ForkAndRun, succeeding_client_and_failing_service_result_in_correct_return_value) { auto service = [](){ return core::posix::exit::Status::failure; }; auto client = [](){ return core::posix::exit::Status::success; }; auto result = core::testing::fork_and_run(service, client); EXPECT_FALSE(ClientFailed(result)); EXPECT_TRUE(ServiceFailed(result)); } TEST(ForkAndRun, failing_client_and_failing_service_result_in_correct_return_value) { auto service = [](){ return core::posix::exit::Status::failure; }; auto client = [](){ return core::posix::exit::Status::failure; }; auto result = core::testing::fork_and_run(service, client); EXPECT_TRUE(ClientFailed(result)); EXPECT_TRUE(ServiceFailed(result)); } TEST(ForkAndRun, throwing_client_is_reported_as_failing) { auto service = [](){ return core::posix::exit::Status::success; }; auto client = [](){ throw std::runtime_error("failing client"); return core::posix::exit::Status::success; }; auto result = core::testing::fork_and_run(service, client); EXPECT_TRUE(ClientFailed(result)); EXPECT_FALSE(ServiceFailed(result)); } TEST(ForkAndRun, exiting_with_failure_client_is_reported_as_failing) { auto service = [](){ return core::posix::exit::Status::success; }; auto client = [](){ exit(EXIT_FAILURE); return core::posix::exit::Status::success; }; auto result = core::testing::fork_and_run(service, client); EXPECT_TRUE(ClientFailed(result)); EXPECT_FALSE(ServiceFailed(result)); } TEST(ForkAndRun, aborting_client_is_reported_as_failing) { auto service = [](){ return core::posix::exit::Status::success; }; auto client = [](){ abort(); return core::posix::exit::Status::success; }; auto result = core::testing::fork_and_run(service, client); EXPECT_TRUE(ClientFailed(result)); EXPECT_FALSE(ServiceFailed(result)); } TESTP(TestingMacros, test_fp_macro_reports_success_for_passing_test, { return core::posix::exit::Status::success; }) TESTP_F(TestingMacrosFixture, test_fp_macro_reports_success_for_passing_test, { return core::posix::exit::Status::success; }) // The following two tests fail, and rightly so. However, translating this // failing behavior to success is really difficult and we omit it for now. TESTP(TestingMacros, DISABLED_test_fp_macro_reports_success_for_failing_test, { return core::posix::exit::Status::failure; }) TESTP_F(TestingMacrosFixture, DISABLED_test_fp_macro_reports_success_for_failing_test, { return core::posix::exit::Status::failure; }) #include TEST(BacktraceSymbolDemangling, demangling_a_cpp_symbol_works) { const char* ref = "tests/fork_and_run_test(_ZN7testing8internal35HandleExceptionsInMethodIfSupportedINS0_12UnitTestImplEbEET0_PT_MS4_FS3_vEPKc+0x4b) [0x4591f8]"; const char* ref_demangled = "bool testing::internal::HandleExceptionsInMethodIfSupported(testing::internal::UnitTestImpl*, bool (testing::internal::UnitTestImpl::*)(), char const*)"; auto symbol = core::posix::backtrace::Frame::Symbol::for_testing_from_raw_symbol(ref); EXPECT_TRUE(symbol->is_cxx()); EXPECT_EQ(ref, symbol->raw()); EXPECT_EQ(ref_demangled, symbol->demangled()); } process-cpp-1.0.0+14.04.20140328/tests/cross_process_sync_test.cpp0000644000015201777760000000401012315241606025171 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include TEST(CrossProcessSync, signalling_the_sync_object_results_in_correct_count) { core::testing::CrossProcessSync cps; auto service = [&cps]() { for (unsigned int i = 1; i <= 50; i++) { EXPECT_NO_THROW(cps.try_signal_ready_for(std::chrono::milliseconds{500})); } return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; auto client = [&cps]() { std::uint32_t counter = 0; for (unsigned int i = 1; i <= 50; i++) { EXPECT_NO_THROW(counter = cps.wait_for_signal_ready_for(std::chrono::milliseconds{500})); EXPECT_EQ(i, counter); } return ::testing::Test::HasFailure() ? core::posix::exit::Status::failure : core::posix::exit::Status::success; }; EXPECT_EQ(core::testing::ForkAndRunResult::empty, core::testing::fork_and_run(service, client)); } TEST(CrossProcessSync, timed_out_wait_on_sync_object_throws_correct_exception) { core::testing::CrossProcessSync cps; EXPECT_THROW(cps.wait_for_signal_ready_for(std::chrono::milliseconds{1}), core::testing::CrossProcessSync::Error::Timeout); } process-cpp-1.0.0+14.04.20140328/tests/CMakeLists.txt0000644000015201777760000000562412315241606022257 0ustar pbusernogroup00000000000000# 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 # Build with system gmock and embedded gtest set (GMOCK_INCLUDE_DIR "/usr/include/gmock/include" CACHE PATH "gmock source include directory") set (GMOCK_SOURCE_DIR "/usr/src/gmock" CACHE PATH "gmock source directory") set (GTEST_INCLUDE_DIR "${GMOCK_SOURCE_DIR}/gtest/include" CACHE PATH "gtest source include directory") set (GMOCK_BOTH_LIBRARIES gmock gmock_main) add_subdirectory(${GMOCK_SOURCE_DIR} "${CMAKE_CURRENT_BINARY_DIR}/gmock") #set (OLD_CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) # Don't treat warnings as errors in 3rd_party/{gmock,cucumber-cpp} #string (REPLACE " -Werror " " " CMAKE_CXX_FLAGS ${CMAKE_CXX_FLAGS}) #find_package(Gtest REQUIRED) include_directories(${GMOCK_INCLUDE_DIR} ${GTEST_INCLUDE_DIR}) #set (CMAKE_CXX_FLAGS ${OLD_CMAKE_CXX_FLAGS}) include_directories( ${CMAKE_SOURCE_DIR}/src ${GTEST_INCLUDE_DIR} ) add_executable( posix_process_test posix_process_test.cpp ) add_executable( linux_process_test linux_process_test.cpp ) add_executable( fork_and_run_test fork_and_run_test.cpp # We include an external source file to prevent from leaking # symbols to the outside world ${CMAKE_SOURCE_DIR}/src/core/posix/backtrace.cpp ) add_executable( cross_process_sync_test cross_process_sync_test.cpp ) add_executable( death_observer_test death_observer_test.cpp ) target_link_libraries( posix_process_test process-cpp ${CMAKE_THREAD_LIBS_INIT} ${GMOCK_BOTH_LIBRARIES} ) target_link_libraries( linux_process_test process-cpp ${CMAKE_THREAD_LIBS_INIT} ${GMOCK_BOTH_LIBRARIES} ) target_link_libraries( fork_and_run_test process-cpp ${CMAKE_THREAD_LIBS_INIT} ${GMOCK_BOTH_LIBRARIES} ) target_link_libraries( cross_process_sync_test process-cpp ${CMAKE_THREAD_LIBS_INIT} ${GMOCK_BOTH_LIBRARIES} ) target_link_libraries( death_observer_test process-cpp ${CMAKE_THREAD_LIBS_INIT} ${GMOCK_BOTH_LIBRARIES} ) add_test(posix_process_test ${CMAKE_CURRENT_BINARY_DIR}/posix_process_test) add_test(linux_process_test ${CMAKE_CURRENT_BINARY_DIR}/linux_process_test) add_test(fork_and_run_test ${CMAKE_CURRENT_BINARY_DIR}/fork_and_run_test) add_test(cross_process_sync_test ${CMAKE_CURRENT_BINARY_DIR}/cross_process_sync_test) add_test(death_observer_test ${CMAKE_CURRENT_BINARY_DIR}/death_observer_test) process-cpp-1.0.0+14.04.20140328/tests/posix_process_test.cpp0000644000015201777760000004522112315241615024157 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include #include #include #include #include #include namespace { ::testing::AssertionResult is_error(const std::error_code& ec) { return ec ? ::testing::AssertionResult{true} : ::testing::AssertionResult{false}; } struct ForkedSpinningProcess : public ::testing::Test { void SetUp() { child = core::posix::fork( []() { std::cout << "Child" << std::endl; while(true) {} return core::posix::exit::Status::failure;}, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout); } void TearDown() { } core::posix::ChildProcess child = core::posix::ChildProcess::invalid(); }; struct Init { Init() : signal_trap( core::posix::trap_signals_for_all_subsequent_threads( {core::posix::Signal::sig_chld})), death_observer( core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap( signal_trap)) { } std::shared_ptr signal_trap; std::unique_ptr death_observer; } init; } TEST(PosixProcess, ctor_throws_for_invalid_pid) { pid_t invalid_pid{-1}; EXPECT_ANY_THROW(core::posix::Process{invalid_pid}); } TEST(PosixProcess, this_process_instance_reports_correct_pid) { EXPECT_EQ(getpid(), core::posix::this_process::instance().pid()); } TEST(PosixProcess, this_process_instance_reports_correct_parent) { EXPECT_EQ(getppid(), core::posix::this_process::parent().pid()); } TEST(PosixProcess, throwing_access_to_process_group_id_of_this_process_works) { EXPECT_EQ(getpgrp(), core::posix::this_process::instance().process_group_or_throw().id()); } TEST(PosixProcess, non_throwing_access_to_process_group_id_of_this_process_works) { std::error_code se; auto pg = core::posix::this_process::instance().process_group(se); EXPECT_FALSE(is_error(se)); EXPECT_EQ(getpgrp(), pg.id()); } TEST(PosixProcess, trying_to_access_process_group_of_invalid_process_throws) { EXPECT_ANY_THROW(core::posix::Process::invalid().process_group_or_throw()); } TEST(PosixProcess, trying_to_access_process_group_of_invalid_process_reports_error) { std::error_code se; core::posix::Process::invalid().process_group(se); EXPECT_TRUE(is_error(se)); } TEST_F(ForkedSpinningProcess, throwing_access_to_process_group_id_of_a_forked_process_works) { auto pg = child.process_group_or_throw(); EXPECT_EQ(getpgrp(), pg.id()); } TEST_F(ForkedSpinningProcess, non_throwing_access_to_process_group_id_of_a_forked_process_works) { std::error_code se; auto pg = child.process_group(se); EXPECT_FALSE(se); EXPECT_EQ(getpgrp(), pg.id()); } TEST(PosixProcess, accessing_streams_of_this_process_works) { { std::stringstream ss; auto old = core::posix::this_process::cout().rdbuf(ss.rdbuf()); core::posix::this_process::cout() << "core::posix::this_process::instance().cout()\n"; EXPECT_EQ(ss.str(), "core::posix::this_process::instance().cout()\n"); core::posix::this_process::cout().rdbuf(old); } { std::stringstream ss; auto old = core::posix::this_process::cerr().rdbuf(ss.rdbuf()); core::posix::this_process::cerr() << "core::posix::this_process::instance().cerr()" << std::endl; EXPECT_EQ(ss.str(), "core::posix::this_process::instance().cerr()\n"); core::posix::this_process::cerr().rdbuf(old); } } TEST(Self, non_mutable_access_to_the_environment_returns_correct_results) { static const char* home = "HOME"; static const char* totally_not_existent = "totally_not_existent_42"; EXPECT_EQ(getenv("HOME"), core::posix::this_process::env::get(home)); EXPECT_EQ("", core::posix::this_process::env::get(totally_not_existent)); } TEST(Self, mutable_access_to_the_environment_alters_the_environment) { static const char* totally_not_existent = "totally_not_existent_42"; static const char* totally_not_existent_value = "42"; EXPECT_EQ("", core::posix::this_process::env::get(totally_not_existent)); EXPECT_NO_THROW(core::posix::this_process::env::set_or_throw( totally_not_existent, totally_not_existent_value)); EXPECT_EQ(totally_not_existent_value, core::posix::this_process::env::get(totally_not_existent)); EXPECT_NO_THROW( core::posix::this_process::env::unset_or_throw( totally_not_existent)); EXPECT_EQ("", core::posix::this_process::env::get(totally_not_existent)); } TEST(Self, getting_env_var_for_empty_key_does_not_throw) { EXPECT_NO_THROW(core::posix::this_process::env::get("")); } TEST(Self, setting_env_var_for_empty_key_throws) { EXPECT_ANY_THROW(core::posix::this_process::env::set_or_throw( "", "uninteresting")); } TEST(ChildProcess, fork_returns_process_object_with_valid_pid_and_wait_for_returns_correct_result) { core::posix::ChildProcess child = core::posix::fork( []() { std::cout << "Child" << std::endl; return core::posix::exit::Status::success; }, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout); EXPECT_TRUE(child.pid() > 0); 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); child = core::posix::fork( []() { std::cout << "Child" << std::endl; return core::posix::exit::Status::failure; }, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout); EXPECT_TRUE(child.pid() > 0); 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::failure, result.detail.if_exited.status); } TEST_F(ForkedSpinningProcess, signalling_a_forked_child_makes_wait_for_return_correct_result) { EXPECT_NO_THROW(child.send_signal_or_throw(core::posix::Signal::sig_kill)); auto result = child.wait_for(core::posix::wait::Flags::untraced); EXPECT_EQ(core::posix::wait::Result::Status::signaled, result.status); EXPECT_EQ(core::posix::Signal::sig_kill, result.detail.if_signaled.signal); child = core::posix::fork( []() { std::cout << "Child" << std::endl; while(true) {} return core::posix::exit::Status::failure;}, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout); EXPECT_TRUE(child.pid() > 0); EXPECT_NO_THROW(child.send_signal_or_throw(core::posix::Signal::sig_term)); result = child.wait_for(core::posix::wait::Flags::untraced); EXPECT_EQ(core::posix::wait::Result::Status::signaled, result.status); EXPECT_EQ(core::posix::Signal::sig_term, result.detail.if_signaled.signal); } TEST(ChildProcess, stopping_a_forked_child_makes_wait_for_return_correct_result) { core::posix::ChildProcess child = core::posix::fork( []() { std::string line; while(true) { std::cin >> line; std::cout << line << std::endl; } return core::posix::exit::Status::failure; }, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout); EXPECT_TRUE(child.pid() > 0); const std::string echo_value{"42"}; child.cin() << echo_value << std::endl; std::string line; child.cout() >> line; EXPECT_EQ(echo_value, line); EXPECT_NO_THROW(child.send_signal_or_throw(core::posix::Signal::sig_stop)); auto result = child.wait_for(core::posix::wait::Flags::untraced); EXPECT_EQ(core::posix::wait::Result::Status::stopped, result.status); EXPECT_EQ(core::posix::Signal::sig_stop, result.detail.if_stopped.signal); EXPECT_NO_THROW(child.send_signal_or_throw(core::posix::Signal::sig_kill)); result = child.wait_for(core::posix::wait::Flags::untraced); EXPECT_EQ(core::posix::wait::Result::Status::signaled, result.status); EXPECT_EQ(core::posix::Signal::sig_kill, result.detail.if_signaled.signal); } TEST(ChildProcess, exec_returns_process_object_with_valid_pid_and_wait_for_returns_correct_result) { const std::string program{"/usr/bin/sleep"}; const std::vector argv = {"10"}; std::map env; core::posix::this_process::env::for_each([&env](const std::string& key, const std::string& value) { env.insert(std::make_pair(key, value)); }); core::posix::ChildProcess child = core::posix::exec(program, argv, env, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout); EXPECT_TRUE(child.pid() > 0); EXPECT_NO_THROW(child.send_signal_or_throw(core::posix::Signal::sig_kill)); auto result = child.wait_for(core::posix::wait::Flags::untraced); EXPECT_EQ(core::posix::wait::Result::Status::signaled, result.status); EXPECT_EQ(core::posix::Signal::sig_kill, result.detail.if_signaled.signal); } TEST(ChildProcess, signalling_an_execd_child_makes_wait_for_return_correct_result) { const std::string program{"/usr/bin/env"}; const std::vector argv = {}; std::map env; core::posix::this_process::env::for_each([&env](const std::string& key, const std::string& value) { env.insert(std::make_pair(key, value)); }); core::posix::ChildProcess child = core::posix::exec( program, argv, env, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout); EXPECT_TRUE(child.pid() > 0); EXPECT_NO_THROW(child.send_signal_or_throw(core::posix::Signal::sig_kill)); auto result = child.wait_for(core::posix::wait::Flags::untraced); EXPECT_EQ(core::posix::wait::Result::Status::signaled, result.status); EXPECT_EQ(core::posix::Signal::sig_kill, result.detail.if_signaled.signal); child = core::posix::exec(program, argv, env, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout); EXPECT_TRUE(child.pid() > 0); EXPECT_NO_THROW(child.send_signal_or_throw(core::posix::Signal::sig_term)); result = child.wait_for(core::posix::wait::Flags::untraced); EXPECT_EQ(core::posix::wait::Result::Status::signaled, result.status); EXPECT_EQ(core::posix::Signal::sig_term, result.detail.if_signaled.signal); } TEST(ChildProcess, stopping_an_execd_child_makes_wait_for_return_correct_result) { const std::string program{"/usr/bin/sleep"}; const std::vector argv = {"10"}; std::map env; core::posix::this_process::env::for_each([&env](const std::string& key, const std::string& value) { env.insert(std::make_pair(key, value)); }); core::posix::ChildProcess child = core::posix::exec(program, argv, env, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout); EXPECT_TRUE(child.pid() > 0); EXPECT_NO_THROW(child.send_signal_or_throw(core::posix::Signal::sig_stop)); auto result = child.wait_for(core::posix::wait::Flags::untraced); EXPECT_EQ(core::posix::wait::Result::Status::stopped, result.status); EXPECT_EQ(core::posix::Signal::sig_stop, result.detail.if_signaled.signal); EXPECT_NO_THROW(child.send_signal_or_throw(core::posix::Signal::sig_kill)); result = child.wait_for(core::posix::wait::Flags::untraced); EXPECT_EQ(core::posix::wait::Result::Status::signaled, result.status); EXPECT_EQ(core::posix::Signal::sig_kill, result.detail.if_signaled.signal); } namespace { struct ChildDeathObserverEventCollector { MOCK_METHOD1(on_child_died,void(const core::posix::Process&)); }; } TEST_F(ForkedSpinningProcess, observing_child_processes_for_death_works_if_child_is_signalled_with_sigkill) { using namespace ::testing; ChildDeathObserverEventCollector event_collector; core::ScopedConnection sc { init.death_observer->child_died().connect([&event_collector](core::posix::ChildProcess cp) { event_collector.on_child_died(cp); }) }; EXPECT_TRUE(init.death_observer->add(child)); EXPECT_CALL(event_collector, on_child_died(_)) .Times(1) .WillOnce( InvokeWithoutArgs( init.signal_trap.get(), &core::posix::SignalTrap::stop)); std::thread worker{[]() { init.signal_trap->run(); }}; child.send_signal_or_throw(core::posix::Signal::sig_kill); if (worker.joinable()) worker.join(); } TEST_F(ForkedSpinningProcess, observing_child_processes_for_death_works_if_child_is_signalled_with_sigterm) { using namespace ::testing; ChildDeathObserverEventCollector signal_trap; EXPECT_TRUE(init.death_observer->add(child)); core::ScopedConnection sc { init.death_observer->child_died().connect([&signal_trap](const core::posix::ChildProcess& child) { signal_trap.on_child_died(child); }) }; EXPECT_CALL(signal_trap, on_child_died(_)) .Times(1) .WillOnce( InvokeWithoutArgs( init.signal_trap.get(), &core::posix::SignalTrap::stop)); std::thread worker{[]() { init.signal_trap->run(); }}; child.send_signal_or_throw(core::posix::Signal::sig_term); if (worker.joinable()) worker.join(); } TEST(ChildProcess, ensure_that_forked_children_are_cleaned_up) { static const unsigned int child_process_count = 100; unsigned int counter = 1; core::ScopedConnection sc { init.death_observer->child_died().connect([&counter](const core::posix::ChildProcess&) { counter++; if (counter == child_process_count) { init.signal_trap->stop(); } }) }; std::thread t([]() {init.signal_trap->run();}); for (unsigned int i = 0; i < child_process_count; i++) { auto child = core::posix::fork( []() { return core::posix::exit::Status::success; }, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout); init.death_observer->add(child); // A bit ugly but we have to ensure that no signal is lost. // And thus, we keep the process object alive. std::this_thread::sleep_for(std::chrono::milliseconds{5}); } if (t.joinable()) t.join(); EXPECT_EQ(child_process_count, counter); } TEST(StreamRedirect, redirecting_stdin_stdout_stderr_works) { core::posix::ChildProcess child = core::posix::fork( []() { std::string line; while(true) { std::cin >> line; std::cout << line << std::endl; std::cerr << line << std::endl; } return core::posix::exit::Status::failure; }, core::posix::StandardStream::stdin | core::posix::StandardStream::stdout | core::posix::StandardStream::stderr); ASSERT_TRUE(child.pid() > 0); const std::string echo_value{"42"}; child.cin() << echo_value << std::endl; std::string line; EXPECT_NO_THROW(child.cout() >> line); EXPECT_EQ(echo_value, line); EXPECT_NO_THROW(child.cerr() >> line); EXPECT_EQ(echo_value, line); EXPECT_NO_THROW(child.send_signal_or_throw(core::posix::Signal::sig_kill)); child.wait_for(core::posix::wait::Flags::untraced); } TEST(Environment, iterating_the_environment_does_not_throw) { EXPECT_NO_THROW(core::posix::this_process::env::for_each( [](const std::string& key, const std::string& value) { std::cout << key << " -> " << value << std::endl; });); } TEST(Environment, specifying_default_value_for_get_returns_correct_result) { const std::string expected_value{"42"}; EXPECT_EQ(expected_value, core::posix::this_process::env::get("totally_non_existant_key_in_env_blubb", expected_value)); } TEST(Environment, for_each_returns_correct_results) { std::array env_keys = {"totally_non_existant_key_in_env_blubb0", "totally_non_existant_key_in_env_blubb1", "totally_non_existant_key_in_env_blubb2"}; std::array env_vars = {env_keys[0] + "=" + "hello", env_keys[1] + "=" + "", env_keys[2] + "=" + "string=hello"}; for( auto const& env_var : env_vars ) { ::putenv(const_cast(env_var.c_str())); } core::posix::this_process::env::for_each([env_keys](const std::string& key, const std::string& value) { if (key == env_keys[0]) { EXPECT_EQ("hello", value); } else if (key == env_keys[1]) { EXPECT_EQ("", value); } else if (key == env_keys[2]) { EXPECT_EQ("string=hello", value); } }); } process-cpp-1.0.0+14.04.20140328/tests/death_observer_test.cpp0000644000015201777760000000263612315241606024256 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include TESTP(DeathObserver, construction_and_deconstruction_works, { auto trap = core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_chld}); EXPECT_NO_THROW(auto death_observer = core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap(trap)); }) TESTP(DeathObserver, construction_with_a_trap_not_including_sig_chld_throws, { auto trap = core::posix::trap_signals_for_all_subsequent_threads({core::posix::Signal::sig_term}); EXPECT_ANY_THROW(auto death_observer = core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap(trap)); }) process-cpp-1.0.0+14.04.20140328/tests/linux_process_test.cpp0000644000015201777760000001460112315241606024152 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include #include #include #include #include TEST(LinuxProcess, accessing_proc_stats_works) { auto child = core::posix::fork( [](){ while(true); return core::posix::exit::Status::success;}, core::posix::StandardStream::empty); core::posix::linux::proc::process::Stat stat; EXPECT_NO_THROW(child >> stat); ASSERT_EQ(core::posix::linux::proc::process::State::running, stat.state); } TEST(LinuxProcess, accessing_proc_oom_score_works) { core::posix::linux::proc::process::OomScore oom_score; EXPECT_NO_THROW(core::posix::this_process::instance() >> oom_score); } TEST(LinuxProcess, accessing_proc_oom_score_adj_works) { core::posix::linux::proc::process::OomScoreAdj oom_score_adj; EXPECT_NO_THROW(core::posix::this_process::instance() >> oom_score_adj); } namespace { // A custom predicate to evaluate values in /proc/pid/oom_score. // The file contains the oom_score as calculated by the kernel and we are racing // against the badness heuristics. However, we only accept values within an error // margin of 10 as the test process does not extensively allocate memory, uses hw devices etc.. ::testing::AssertionResult is_approximately_equal(int a, int b) { static const int error_margin = 10; if (::abs(a-b) <= 10) return ::testing::AssertionSuccess() << ::abs(a-b) << " <= " << error_margin; return ::testing::AssertionFailure() << ::abs(a-b) << " > " << error_margin; } } TEST(LinuxProcess, adjusting_proc_oom_score_adj_works) { core::posix::linux::proc::process::OomScoreAdj oom_score_adj { core::posix::linux::proc::process::OomScoreAdj::max_value() }; EXPECT_NO_THROW(core::posix::this_process::instance() << oom_score_adj); EXPECT_NO_THROW(core::posix::this_process::instance() >> oom_score_adj); EXPECT_EQ(core::posix::linux::proc::process::OomScoreAdj::max_value(), oom_score_adj.value); core::posix::linux::proc::process::OomScore oom_score; EXPECT_NO_THROW(core::posix::this_process::instance() >> oom_score); EXPECT_TRUE(is_approximately_equal(oom_score.value, core::posix::linux::proc::process::OomScoreAdj::max_value())); } // For this test we assume that we are not privileged and that the test binary // does not have CAP_SYS_RESOURCE capabilities. TEST(LinuxProcess, adjusting_proc_oom_score_adj_to_privileged_values_only_works_if_root) { core::posix::linux::proc::process::OomScoreAdj oom_score_adj { core::posix::linux::proc::process::OomScoreAdj::min_value() }; EXPECT_NO_THROW(core::posix::this_process::instance() << oom_score_adj); EXPECT_NO_THROW(core::posix::this_process::instance() >> oom_score_adj); // If we are running on virtualized builders or buildds we are running under a fakeroot environment. // However, that environment does not give us the required privileges and capabilities to adjust OOM values // as we like. At any rate, this check seems to be flaky and we just comment it out. // EXPECT_NE(core::posix::linux::proc::process::OomScoreAdj::min_value(), // oom_score_adj.value); } TEST(LinuxProcess, trying_to_write_an_invalid_oom_score_adj_throws) { core::posix::linux::proc::process::OomScoreAdj invalid_adj { core::posix::linux::proc::process::OomScoreAdj::min_value() -1000 }; EXPECT_ANY_THROW(core::posix::this_process::instance() << invalid_adj); } TEST(LinuxProcess, adjusting_proc_oom_adj_works) { core::posix::linux::proc::process::OomAdj oom_adj { core::posix::linux::proc::process::OomAdj::max_value() }; EXPECT_NO_THROW(core::posix::this_process::instance() << oom_adj); EXPECT_NO_THROW(core::posix::this_process::instance() >> oom_adj); EXPECT_EQ(core::posix::linux::proc::process::OomAdj::max_value(), oom_adj.value); core::posix::linux::proc::process::OomScore oom_score; EXPECT_NO_THROW(core::posix::this_process::instance() >> oom_score); // This looks weird as we are comparing to OomScoreAdj as opposed to OomAdj. // However, /proc/pid/oom_adj is deprecated as of linux 2.6.36 and the value // reported in oom_score is in the scale of /proc/pid/oom_score_adj, i.e., [-1000, 1000]. EXPECT_TRUE(is_approximately_equal(oom_score.value, core::posix::linux::proc::process::OomScoreAdj::max_value())); } // For this test we assume that we are not privileged and that the test binary // does not have CAP_SYS_RESOURCE capabilities. TEST(LinuxProcess, adjusting_proc_oom_adj_to_privileged_values_does_not_work) { core::posix::linux::proc::process::OomAdj oom_adj { core::posix::linux::proc::process::OomAdj::min_value() }; EXPECT_NO_THROW(core::posix::this_process::instance() << oom_adj); EXPECT_NO_THROW(core::posix::this_process::instance() >> oom_adj); // If we are running on virtualized builders or buildds we are running under a fakeroot environment. // However, that environment does not give us the required privileges and capabilities to adjust OOM values // as we like. At any rate, this check seems to be flaky and we just comment it out. // EXPECT_NE(core::posix::linux::proc::process::OomAdj::min_value(), // oom_adj.value); } TEST(LinuxProcess, trying_to_write_an_invalid_oom_adj_throws) { core::posix::linux::proc::process::OomAdj invalid_adj { core::posix::linux::proc::process::OomAdj::min_value() - 1000 }; EXPECT_ANY_THROW(core::posix::this_process::instance() << invalid_adj); } process-cpp-1.0.0+14.04.20140328/symbols.map0000644000015201777760000000034512315241606020537 0ustar pbusernogroup00000000000000{ global: extern "C++" { core::*; typeinfo?for?core::*; typeinfo?name?for?core::*; VTT?for?core::*; virtual?thunk?to?core::*; vtable?for?core::*; std::hash*; }; local: extern "C++" { *; }; };process-cpp-1.0.0+14.04.20140328/CMakeLists.txt0000644000015201777760000000534412315241606021114 0ustar pbusernogroup00000000000000# 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 cmake_minimum_required(VERSION 2.8) project(process-cpp) find_package(Boost COMPONENTS iostreams system REQUIRED) find_package(PkgConfig REQUIRED) find_package(Threads REQUIRED) pkg_check_modules(PROPERTIES_CPP properties-cpp) set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${CMAKE_CURRENT_SOURCE_DIR}/cmake) include(GNUInstallDirs) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -pedantic -Wextra -fvisibility=hidden") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -Wall -fno-strict-aliasing -fvisibility=hidden -fvisibility-inlines-hidden -pedantic -Wextra") set(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -Wl,--no-undefined") option(PROCESS_CPP_WERROR "Treat warnings as errors" ON) if(PROCESS_CPP_WERROR) set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Werror -Wno-error=format") set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Werror -Wno-error=format") endif(PROCESS_CPP_WERROR) string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) ##################################################################### # Enable code coverage calculation with gcov/gcovr/lcov # Usage: # * Switch build type to coverage (use ccmake or cmake-gui) # * Invoke make, make test, make coverage # * Find html report in subdir coveragereport # * Find xml report feasible for jenkins in coverage.xml ##################################################################### IF(cmake_build_type_lower MATCHES coverage) SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -ftest-coverage -fprofile-arcs" ) SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -ftest-coverage -fprofile-arcs" ) SET(CMAKE_MODULE_LINKER_FLAGS "${CMAKE_MODULE_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" ) SET(CMAKE_SHARED_LINKER_FLAGS "${CMAKE_SHARED_LINKER_FLAGS} -ftest-coverage -fprofile-arcs" ) ENDIF(cmake_build_type_lower MATCHES coverage) set(PROCESS_CPP_VERSION_MAJOR 1) set(PROCESS_CPP_VERSION_MINOR 0) set(PROCESS_CPP_VERSION_PATCH 0) include(CTest) include_directories( include/ ${Boost_INCLUDE_DIRS} ${PROPERTIES_CPP_INCLUDE_DIRS} ) add_subdirectory(doc) add_subdirectory(data) add_subdirectory(include) add_subdirectory(src) add_subdirectory(tests) process-cpp-1.0.0+14.04.20140328/README.md0000644000015201777760000000653212315241606017633 0ustar pbusernogroup00000000000000process-cpp {#mainpage} =========== process-cpp is a simple and straightforward wrapper around process creation and control targeted towards linux. It helps both with handling child processes and with interacting with the current process. Some of its features include: - Thread-safe get/set/unset operation on the current process's environment. - Throwing and non-throwing overloads of functions when system calls are involved. - Seamless redirection of input, output and error streams of child processes. - Type-safe interaction with the virtual proc filesystem, both for reading & writing. The library's main purpose is to assist in testing and when a software component needs to carry out process creation/control tasks, e.g., a graphical shell. To this end, the library is extensively tested and tries to ensure fail-safe operation as much as possible. A simple echo ------------- ~~~~~~~~~~~~~{.cpp} // Fork and run a simple echo: posix::ChildProcess child = posix::fork( []() { std::string line; while(true) { std::cin >> line; std::cout << line << std::endl; } return EXIT_FAILURE; }, posix::StandardStreamFlags() .set(posix::StandardStream::stdin) .set(posix::StandardStream::stdout)); // Check that the resulting process has a valid pid. EXPECT_TRUE(child.pid() > 0); // Check on echo functionality. const std::string echo_value{"42"}; child.cin() << echo_value << std::endl; std::string line; child.cout() >> line; EXPECT_EQ(echo_value, line); // Stop the process and synchronize with the process changing state. EXPECT_NO_THROW(child.send_signal(posix::Signal::sig_stop)); auto result = child.wait_for(posix::wait::Flag::untraced); EXPECT_EQ(posix::wait::Result::Status::stopped, result.status); EXPECT_EQ(posix::Signal::sig_stop, result.detail.if_stopped.signal); // Kill the stopped process and synchronize to its state change. EXPECT_NO_THROW(child.send_signal(posix::Signal::sig_kill)); result = child.wait_for(posix::wait::Flag::untraced); EXPECT_EQ(posix::wait::Result::Status::signaled, result.status); EXPECT_EQ(posix::Signal::sig_kill, result.detail.if_signaled.signal); ~~~~~~~~~~~~~ Adjusting OOM Score Values -------------------------- ~~~~~~~~~~~~~{.cpp} // Setup the manipulator with a well-known value. posix::linux::proc::process::OomScoreAdj oom_score_adj { posix::linux::proc::process::OomScoreAdj::max_value() }; // Apply the manipulator to the current process EXPECT_NO_THROW(posix::this_process::instance() << oom_score_adj); // Read back the manipulators value for the current process EXPECT_NO_THROW(posix::this_process::instance() >> oom_score_adj); // And check that applying the manipulator was successful. EXPECT_EQ(posix::linux::proc::process::OomScoreAdj::max_value(), oom_score_adj.value); // Instantiate the observer... posix::linux::proc::process::OomScore oom_score; // ... and fill in its value for the current process. EXPECT_NO_THROW(posix::this_process::instance() >> oom_score); // Check that applying the manipulator before results in adjustments to the // OOM score. EXPECT_TRUE(is_approximately_equal(oom_score.value, posix::linux::proc::process::OomScoreAdj::max_value())); ~~~~~~~~~~~~~ process-cpp-1.0.0+14.04.20140328/doc/0000755000015201777760000000000012315242015017106 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/doc/Doxyfile.in0000644000015201777760000023455312315241606021242 0ustar pbusernogroup00000000000000# Doxyfile 1.8.3.1 # This file describes the settings to be used by the documentation system # doxygen (www.doxygen.org) for a project. # # All text after a hash (#) is considered a comment and will be ignored. # The format is: # TAG = value [value, ...] # For lists items can also be appended using: # TAG += value [value, ...] # Values that contain spaces should be placed between quotes (" "). #--------------------------------------------------------------------------- # Project related configuration options #--------------------------------------------------------------------------- # This tag specifies the encoding used for all characters in the config file # that follow. The default is UTF-8 which is also the encoding used for all # text before the first occurrence of this tag. Doxygen uses libiconv (or the # iconv built into libc) for the transcoding. See # http://www.gnu.org/software/libiconv for the list of possible encodings. DOXYFILE_ENCODING = UTF-8 # The PROJECT_NAME tag is a single word (or sequence of words) that should # identify the project. Note that if you do not use Doxywizard you need # to put quotes around the project name if it contains spaces. PROJECT_NAME = @CMAKE_PROJECT_NAME@ # The PROJECT_NUMBER tag can be used to enter a project or revision number. # This could be handy for archiving the generated documentation or # if some version control system is used. PROJECT_NUMBER = @PROCESS_CPP_VERSION_MAJOR@.@PROCESS_CPP_VERSION_MINOR@.@PROCESS_CPP_VERSION_PATCH@ # Using the PROJECT_BRIEF tag one can provide an optional one line description # for a project that appears at the top of each page and should give viewer # a quick idea about the purpose of the project. Keep the description short. PROJECT_BRIEF = "A simple convenience library for handling processes in C++11." # With the PROJECT_LOGO tag one can specify an logo or icon that is # included in the documentation. The maximum height of the logo should not # exceed 55 pixels and the maximum width should not exceed 200 pixels. # Doxygen will copy the logo to the output directory. PROJECT_LOGO = # The OUTPUT_DIRECTORY tag is used to specify the (relative or absolute) # base path where the generated documentation will be put. # If a relative path is entered, it will be relative to the location # where doxygen was started. If left blank the current directory will be used. OUTPUT_DIRECTORY = # If the CREATE_SUBDIRS tag is set to YES, then doxygen will create # 4096 sub-directories (in 2 levels) under the output directory of each output # format and will distribute the generated files over these directories. # Enabling this option can be useful when feeding doxygen a huge amount of # source files, where putting all generated files in the same directory would # otherwise cause performance problems for the file system. CREATE_SUBDIRS = NO # The OUTPUT_LANGUAGE tag is used to specify the language in which all # documentation generated by doxygen is written. Doxygen will use this # information to generate all constant output in the proper language. # The default language is English, other supported languages are: # Afrikaans, Arabic, Brazilian, Catalan, Chinese, Chinese-Traditional, # Croatian, Czech, Danish, Dutch, Esperanto, Farsi, Finnish, French, German, # Greek, Hungarian, Italian, Japanese, Japanese-en (Japanese with English # messages), Korean, Korean-en, Lithuanian, Norwegian, Macedonian, Persian, # Polish, Portuguese, Romanian, Russian, Serbian, Serbian-Cyrillic, Slovak, # Slovene, Spanish, Swedish, Ukrainian, and Vietnamese. OUTPUT_LANGUAGE = English # If the BRIEF_MEMBER_DESC tag is set to YES (the default) Doxygen will # include brief member descriptions after the members that are listed in # the file and class documentation (similar to JavaDoc). # Set to NO to disable this. BRIEF_MEMBER_DESC = YES # If the REPEAT_BRIEF tag is set to YES (the default) Doxygen will prepend # the brief description of a member or function before the detailed description. # Note: if both HIDE_UNDOC_MEMBERS and BRIEF_MEMBER_DESC are set to NO, the # brief descriptions will be completely suppressed. REPEAT_BRIEF = YES # This tag implements a quasi-intelligent brief description abbreviator # that is used to form the text in various listings. Each string # in this list, if found as the leading text of the brief description, will be # stripped from the text and the result after processing the whole list, is # used as the annotated text. Otherwise, the brief description is used as-is. # If left blank, the following values are used ("$name" is automatically # replaced with the name of the entity): "The $name class" "The $name widget" # "The $name file" "is" "provides" "specifies" "contains" # "represents" "a" "an" "the" ABBREVIATE_BRIEF = # If the ALWAYS_DETAILED_SEC and REPEAT_BRIEF tags are both set to YES then # Doxygen will generate a detailed section even if there is only a brief # description. ALWAYS_DETAILED_SEC = NO # If the INLINE_INHERITED_MEMB tag is set to YES, doxygen will show all # inherited members of a class in the documentation of that class as if those # members were ordinary class members. Constructors, destructors and assignment # operators of the base classes will not be shown. INLINE_INHERITED_MEMB = NO # If the FULL_PATH_NAMES tag is set to YES then Doxygen will prepend the full # path before files name in the file list and in the header files. If set # to NO the shortest path that makes the file name unique will be used. FULL_PATH_NAMES = YES # If the FULL_PATH_NAMES tag is set to YES then the STRIP_FROM_PATH tag # can be used to strip a user-defined part of the path. Stripping is # only done if one of the specified strings matches the left-hand part of # the path. The tag can be used to show relative paths in the file list. # If left blank the directory from which doxygen is run is used as the # path to strip. Note that you specify absolute paths here, but also # relative paths, which will be relative from the directory where doxygen is # started. STRIP_FROM_PATH = # The STRIP_FROM_INC_PATH tag can be used to strip a user-defined part of # the path mentioned in the documentation of a class, which tells # the reader which header file to include in order to use a class. # If left blank only the name of the header file containing the class # definition is used. Otherwise one should specify the include paths that # are normally passed to the compiler using the -I flag. STRIP_FROM_INC_PATH = # If the SHORT_NAMES tag is set to YES, doxygen will generate much shorter # (but less readable) file names. This can be useful if your file system # doesn't support long names like on DOS, Mac, or CD-ROM. SHORT_NAMES = NO # If the JAVADOC_AUTOBRIEF tag is set to YES then Doxygen # will interpret the first line (until the first dot) of a JavaDoc-style # comment as the brief description. If set to NO, the JavaDoc # comments will behave just like regular Qt-style comments # (thus requiring an explicit @brief command for a brief description.) JAVADOC_AUTOBRIEF = NO # If the QT_AUTOBRIEF tag is set to YES then Doxygen will # interpret the first line (until the first dot) of a Qt-style # comment as the brief description. If set to NO, the comments # will behave just like regular Qt-style comments (thus requiring # an explicit \brief command for a brief description.) QT_AUTOBRIEF = NO # The MULTILINE_CPP_IS_BRIEF tag can be set to YES to make Doxygen # treat a multi-line C++ special comment block (i.e. a block of //! or /// # comments) as a brief description. This used to be the default behaviour. # The new default is to treat a multi-line C++ comment block as a detailed # description. Set this tag to YES if you prefer the old behaviour instead. MULTILINE_CPP_IS_BRIEF = NO # If the INHERIT_DOCS tag is set to YES (the default) then an undocumented # member inherits the documentation from any documented member that it # re-implements. INHERIT_DOCS = YES # If the SEPARATE_MEMBER_PAGES tag is set to YES, then doxygen will produce # a new page for each member. If set to NO, the documentation of a member will # be part of the file/class/namespace that contains it. SEPARATE_MEMBER_PAGES = NO # The TAB_SIZE tag can be used to set the number of spaces in a tab. # Doxygen uses this value to replace tabs by spaces in code fragments. TAB_SIZE = 4 # This tag can be used to specify a number of aliases that acts # as commands in the documentation. An alias has the form "name=value". # For example adding "sideeffect=\par Side Effects:\n" will allow you to # put the command \sideeffect (or @sideeffect) in the documentation, which # will result in a user-defined paragraph with heading "Side Effects:". # You can put \n's in the value part of an alias to insert newlines. ALIASES = # This tag can be used to specify a number of word-keyword mappings (TCL only). # A mapping has the form "name=value". For example adding # "class=itcl::class" will allow you to use the command class in the # itcl::class meaning. TCL_SUBST = # Set the OPTIMIZE_OUTPUT_FOR_C tag to YES if your project consists of C # sources only. Doxygen will then generate output that is more tailored for C. # For instance, some of the names that are used will be different. The list # of all members will be omitted, etc. OPTIMIZE_OUTPUT_FOR_C = NO # Set the OPTIMIZE_OUTPUT_JAVA tag to YES if your project consists of Java # sources only. Doxygen will then generate output that is more tailored for # Java. For instance, namespaces will be presented as packages, qualified # scopes will look different, etc. OPTIMIZE_OUTPUT_JAVA = NO # Set the OPTIMIZE_FOR_FORTRAN tag to YES if your project consists of Fortran # sources only. Doxygen will then generate output that is more tailored for # Fortran. OPTIMIZE_FOR_FORTRAN = NO # Set the OPTIMIZE_OUTPUT_VHDL tag to YES if your project consists of VHDL # sources. Doxygen will then generate output that is tailored for # VHDL. OPTIMIZE_OUTPUT_VHDL = NO # Doxygen selects the parser to use depending on the extension of the files it # parses. With this tag you can assign which parser to use for a given # extension. Doxygen has a built-in mapping, but you can override or extend it # using this tag. The format is ext=language, where ext is a file extension, # and language is one of the parsers supported by doxygen: IDL, Java, # Javascript, CSharp, C, C++, D, PHP, Objective-C, Python, Fortran, VHDL, C, # C++. For instance to make doxygen treat .inc files as Fortran files (default # is PHP), and .f files as C (default is Fortran), use: inc=Fortran f=C. Note # that for custom extensions you also need to set FILE_PATTERNS otherwise the # files are not read by doxygen. EXTENSION_MAPPING = # If MARKDOWN_SUPPORT is enabled (the default) then doxygen pre-processes all # comments according to the Markdown format, which allows for more readable # documentation. See http://daringfireball.net/projects/markdown/ for details. # The output of markdown processing is further processed by doxygen, so you # can mix doxygen, HTML, and XML commands with Markdown formatting. # Disable only in case of backward compatibilities issues. MARKDOWN_SUPPORT = YES # When enabled doxygen tries to link words that correspond to documented classes, # or namespaces to their corresponding documentation. Such a link can be # prevented in individual cases by by putting a % sign in front of the word or # globally by setting AUTOLINK_SUPPORT to NO. AUTOLINK_SUPPORT = YES # If you use STL classes (i.e. std::string, std::vector, etc.) but do not want # to include (a tag file for) the STL sources as input, then you should # set this tag to YES in order to let doxygen match functions declarations and # definitions whose arguments contain STL classes (e.g. func(std::string); v.s. # func(std::string) {}). This also makes the inheritance and collaboration # diagrams that involve STL classes more complete and accurate. BUILTIN_STL_SUPPORT = YES # If you use Microsoft's C++/CLI language, you should set this option to YES to # enable parsing support. CPP_CLI_SUPPORT = NO # Set the SIP_SUPPORT tag to YES if your project consists of sip sources only. # Doxygen will parse them like normal C++ but will assume all classes use public # instead of private inheritance when no explicit protection keyword is present. SIP_SUPPORT = NO # For Microsoft's IDL there are propget and propput attributes to indicate # getter and setter methods for a property. Setting this option to YES (the # default) will make doxygen replace the get and set methods by a property in # the documentation. This will only work if the methods are indeed getting or # setting a simple type. If this is not the case, or you want to show the # methods anyway, you should set this option to NO. IDL_PROPERTY_SUPPORT = YES # If member grouping is used in the documentation and the DISTRIBUTE_GROUP_DOC # tag is set to YES, then doxygen will reuse the documentation of the first # member in the group (if any) for the other members of the group. By default # all members of a group must be documented explicitly. DISTRIBUTE_GROUP_DOC = NO # Set the SUBGROUPING tag to YES (the default) to allow class member groups of # the same type (for instance a group of public functions) to be put as a # subgroup of that type (e.g. under the Public Functions section). Set it to # NO to prevent subgrouping. Alternatively, this can be done per class using # the \nosubgrouping command. SUBGROUPING = YES # When the INLINE_GROUPED_CLASSES tag is set to YES, classes, structs and # unions are shown inside the group in which they are included (e.g. using # @ingroup) instead of on a separate page (for HTML and Man pages) or # section (for LaTeX and RTF). INLINE_GROUPED_CLASSES = NO # When the INLINE_SIMPLE_STRUCTS tag is set to YES, structs, classes, and # unions with only public data fields will be shown inline in the documentation # of the scope in which they are defined (i.e. file, namespace, or group # documentation), provided this scope is documented. If set to NO (the default), # structs, classes, and unions are shown on a separate page (for HTML and Man # pages) or section (for LaTeX and RTF). INLINE_SIMPLE_STRUCTS = NO # When TYPEDEF_HIDES_STRUCT is enabled, a typedef of a struct, union, or enum # is documented as struct, union, or enum with the name of the typedef. So # typedef struct TypeS {} TypeT, will appear in the documentation as a struct # with name TypeT. When disabled the typedef will appear as a member of a file, # namespace, or class. And the struct will be named TypeS. This can typically # be useful for C code in case the coding convention dictates that all compound # types are typedef'ed and only the typedef is referenced, never the tag name. TYPEDEF_HIDES_STRUCT = NO # The SYMBOL_CACHE_SIZE determines the size of the internal cache use to # determine which symbols to keep in memory and which to flush to disk. # When the cache is full, less often used symbols will be written to disk. # For small to medium size projects (<1000 input files) the default value is # probably good enough. For larger projects a too small cache size can cause # doxygen to be busy swapping symbols to and from disk most of the time # causing a significant performance penalty. # If the system has enough physical memory increasing the cache will improve the # performance by keeping more symbols in memory. Note that the value works on # a logarithmic scale so increasing the size by one will roughly double the # memory usage. The cache size is given by this formula: # 2^(16+SYMBOL_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. SYMBOL_CACHE_SIZE = 0 # Similar to the SYMBOL_CACHE_SIZE the size of the symbol lookup cache can be # set using LOOKUP_CACHE_SIZE. This cache is used to resolve symbols given # their name and scope. Since this can be an expensive process and often the # same symbol appear multiple times in the code, doxygen keeps a cache of # pre-resolved symbols. If the cache is too small doxygen will become slower. # If the cache is too large, memory is wasted. The cache size is given by this # formula: 2^(16+LOOKUP_CACHE_SIZE). The valid range is 0..9, the default is 0, # corresponding to a cache size of 2^16 = 65536 symbols. LOOKUP_CACHE_SIZE = 0 #--------------------------------------------------------------------------- # Build related configuration options #--------------------------------------------------------------------------- # If the EXTRACT_ALL tag is set to YES doxygen will assume all entities in # documentation are documented, even if no documentation was available. # Private class members and static file members will be hidden unless # the EXTRACT_PRIVATE and EXTRACT_STATIC tags are set to YES EXTRACT_ALL = YES # If the EXTRACT_PRIVATE tag is set to YES all private members of a class # will be included in the documentation. EXTRACT_PRIVATE = NO # If the EXTRACT_PACKAGE tag is set to YES all members with package or internal # scope will be included in the documentation. EXTRACT_PACKAGE = NO # If the EXTRACT_STATIC tag is set to YES all static members of a file # will be included in the documentation. EXTRACT_STATIC = NO # If the EXTRACT_LOCAL_CLASSES tag is set to YES classes (and structs) # defined locally in source files will be included in the documentation. # If set to NO only classes defined in header files are included. EXTRACT_LOCAL_CLASSES = YES # This flag is only useful for Objective-C code. When set to YES local # methods, which are defined in the implementation section but not in # the interface are included in the documentation. # If set to NO (the default) only methods in the interface are included. EXTRACT_LOCAL_METHODS = NO # If this flag is set to YES, the members of anonymous namespaces will be # extracted and appear in the documentation as a namespace called # 'anonymous_namespace{file}', where file will be replaced with the base # name of the file that contains the anonymous namespace. By default # anonymous namespaces are hidden. EXTRACT_ANON_NSPACES = NO # If the HIDE_UNDOC_MEMBERS tag is set to YES, Doxygen will hide all # undocumented members of documented classes, files or namespaces. # If set to NO (the default) these members will be included in the # various overviews, but no documentation section is generated. # This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_MEMBERS = NO # If the HIDE_UNDOC_CLASSES tag is set to YES, Doxygen will hide all # undocumented classes that are normally visible in the class hierarchy. # If set to NO (the default) these classes will be included in the various # overviews. This option has no effect if EXTRACT_ALL is enabled. HIDE_UNDOC_CLASSES = NO # If the HIDE_FRIEND_COMPOUNDS tag is set to YES, Doxygen will hide all # friend (class|struct|union) declarations. # If set to NO (the default) these declarations will be included in the # documentation. HIDE_FRIEND_COMPOUNDS = NO # If the HIDE_IN_BODY_DOCS tag is set to YES, Doxygen will hide any # documentation blocks found inside the body of a function. # If set to NO (the default) these blocks will be appended to the # function's detailed documentation block. HIDE_IN_BODY_DOCS = NO # The INTERNAL_DOCS tag determines if documentation # that is typed after a \internal command is included. If the tag is set # to NO (the default) then the documentation will be excluded. # Set it to YES to include the internal documentation. INTERNAL_DOCS = NO # If the CASE_SENSE_NAMES tag is set to NO then Doxygen will only generate # file names in lower-case letters. If set to YES upper-case letters are also # allowed. This is useful if you have classes or files whose names only differ # in case and if your file system supports case sensitive file names. Windows # and Mac users are advised to set this option to NO. CASE_SENSE_NAMES = YES # If the HIDE_SCOPE_NAMES tag is set to NO (the default) then Doxygen # will show members with their full class and namespace scopes in the # documentation. If set to YES the scope will be hidden. HIDE_SCOPE_NAMES = NO # If the SHOW_INCLUDE_FILES tag is set to YES (the default) then Doxygen # will put a list of the files that are included by a file in the documentation # of that file. SHOW_INCLUDE_FILES = YES # If the FORCE_LOCAL_INCLUDES tag is set to YES then Doxygen # will list include files with double quotes in the documentation # rather than with sharp brackets. FORCE_LOCAL_INCLUDES = NO # If the INLINE_INFO tag is set to YES (the default) then a tag [inline] # is inserted in the documentation for inline members. INLINE_INFO = YES # If the SORT_MEMBER_DOCS tag is set to YES (the default) then doxygen # will sort the (detailed) documentation of file and class members # alphabetically by member name. If set to NO the members will appear in # declaration order. SORT_MEMBER_DOCS = YES # If the SORT_BRIEF_DOCS tag is set to YES then doxygen will sort the # brief documentation of file, namespace and class members alphabetically # by member name. If set to NO (the default) the members will appear in # declaration order. SORT_BRIEF_DOCS = NO # If the SORT_MEMBERS_CTORS_1ST tag is set to YES then doxygen # will sort the (brief and detailed) documentation of class members so that # constructors and destructors are listed first. If set to NO (the default) # the constructors will appear in the respective orders defined by # SORT_MEMBER_DOCS and SORT_BRIEF_DOCS. # This tag will be ignored for brief docs if SORT_BRIEF_DOCS is set to NO # and ignored for detailed docs if SORT_MEMBER_DOCS is set to NO. SORT_MEMBERS_CTORS_1ST = NO # If the SORT_GROUP_NAMES tag is set to YES then doxygen will sort the # hierarchy of group names into alphabetical order. If set to NO (the default) # the group names will appear in their defined order. SORT_GROUP_NAMES = NO # If the SORT_BY_SCOPE_NAME tag is set to YES, the class list will be # sorted by fully-qualified names, including namespaces. If set to # NO (the default), the class list will be sorted only by class name, # not including the namespace part. # Note: This option is not very useful if HIDE_SCOPE_NAMES is set to YES. # Note: This option applies only to the class list, not to the # alphabetical list. SORT_BY_SCOPE_NAME = NO # If the STRICT_PROTO_MATCHING option is enabled and doxygen fails to # do proper type resolution of all parameters of a function it will reject a # match between the prototype and the implementation of a member function even # if there is only one candidate or it is obvious which candidate to choose # by doing a simple string match. By disabling STRICT_PROTO_MATCHING doxygen # will still accept a match between prototype and implementation in such cases. STRICT_PROTO_MATCHING = NO # The GENERATE_TODOLIST tag can be used to enable (YES) or # disable (NO) the todo list. This list is created by putting \todo # commands in the documentation. GENERATE_TODOLIST = YES # The GENERATE_TESTLIST tag can be used to enable (YES) or # disable (NO) the test list. This list is created by putting \test # commands in the documentation. GENERATE_TESTLIST = YES # The GENERATE_BUGLIST tag can be used to enable (YES) or # disable (NO) the bug list. This list is created by putting \bug # commands in the documentation. GENERATE_BUGLIST = YES # The GENERATE_DEPRECATEDLIST tag can be used to enable (YES) or # disable (NO) the deprecated list. This list is created by putting # \deprecated commands in the documentation. GENERATE_DEPRECATEDLIST= YES # The ENABLED_SECTIONS tag can be used to enable conditional # documentation sections, marked by \if section-label ... \endif # and \cond section-label ... \endcond blocks. ENABLED_SECTIONS = # The MAX_INITIALIZER_LINES tag determines the maximum number of lines # the initial value of a variable or macro consists of for it to appear in # the documentation. If the initializer consists of more lines than specified # here it will be hidden. Use a value of 0 to hide initializers completely. # The appearance of the initializer of individual variables and macros in the # documentation can be controlled using \showinitializer or \hideinitializer # command in the documentation regardless of this setting. MAX_INITIALIZER_LINES = 30 # Set the SHOW_USED_FILES tag to NO to disable the list of files generated # at the bottom of the documentation of classes and structs. If set to YES the # list will mention the files that were used to generate the documentation. SHOW_USED_FILES = YES # Set the SHOW_FILES tag to NO to disable the generation of the Files page. # This will remove the Files entry from the Quick Index and from the # Folder Tree View (if specified). The default is YES. SHOW_FILES = YES # Set the SHOW_NAMESPACES tag to NO to disable the generation of the # Namespaces page. # This will remove the Namespaces entry from the Quick Index # and from the Folder Tree View (if specified). The default is YES. SHOW_NAMESPACES = YES # The FILE_VERSION_FILTER tag can be used to specify a program or script that # doxygen should invoke to get the current version for each file (typically from # the version control system). Doxygen will invoke the program by executing (via # popen()) the command , where is the value of # the FILE_VERSION_FILTER tag, and is the name of an input file # provided by doxygen. Whatever the program writes to standard output # is used as the file version. See the manual for examples. FILE_VERSION_FILTER = # The LAYOUT_FILE tag can be used to specify a layout file which will be parsed # by doxygen. The layout file controls the global structure of the generated # output files in an output format independent way. To create the layout file # that represents doxygen's defaults, run doxygen with the -l option. # You can optionally specify a file name after the option, if omitted # DoxygenLayout.xml will be used as the name of the layout file. LAYOUT_FILE = # The CITE_BIB_FILES tag can be used to specify one or more bib files # containing the references data. This must be a list of .bib files. The # .bib extension is automatically appended if omitted. Using this command # requires the bibtex tool to be installed. See also # http://en.wikipedia.org/wiki/BibTeX for more info. For LaTeX the style # of the bibliography can be controlled using LATEX_BIB_STYLE. To use this # feature you need bibtex and perl available in the search path. Do not use # file names with spaces, bibtex cannot handle them. CITE_BIB_FILES = #--------------------------------------------------------------------------- # configuration options related to warning and progress messages #--------------------------------------------------------------------------- # The QUIET tag can be used to turn on/off the messages that are generated # by doxygen. Possible values are YES and NO. If left blank NO is used. QUIET = NO # The WARNINGS tag can be used to turn on/off the warning messages that are # generated by doxygen. Possible values are YES and NO. If left blank # NO is used. WARNINGS = YES # If WARN_IF_UNDOCUMENTED is set to YES, then doxygen will generate warnings # for undocumented members. If EXTRACT_ALL is set to YES then this flag will # automatically be disabled. WARN_IF_UNDOCUMENTED = YES # If WARN_IF_DOC_ERROR is set to YES, doxygen will generate warnings for # potential errors in the documentation, such as not documenting some # parameters in a documented function, or documenting parameters that # don't exist or using markup commands wrongly. WARN_IF_DOC_ERROR = YES # The WARN_NO_PARAMDOC option can be enabled to get warnings for # functions that are documented, but have no documentation for their parameters # or return value. If set to NO (the default) doxygen will only warn about # wrong or incomplete parameter documentation, but not about the absence of # documentation. WARN_NO_PARAMDOC = NO # The WARN_FORMAT tag determines the format of the warning messages that # doxygen can produce. The string should contain the $file, $line, and $text # tags, which will be replaced by the file and line number from which the # warning originated and the warning text. Optionally the format may contain # $version, which will be replaced by the version of the file (if it could # be obtained via FILE_VERSION_FILTER) WARN_FORMAT = "$file:$line: $text" # The WARN_LOGFILE tag can be used to specify a file to which warning # and error messages should be written. If left blank the output is written # to stderr. WARN_LOGFILE = #--------------------------------------------------------------------------- # configuration options related to the input files #--------------------------------------------------------------------------- # The INPUT tag can be used to specify the files and/or directories that contain # documented source files. You may enter file names like "myfile.cpp" or # directories like "/usr/src/myproject". Separate the files or directories # with spaces. INPUT = @CMAKE_SOURCE_DIR@ @CMAKE_CURRENT_SOURCE_DIR@ @CMAKE_CURRENT_SOURCE_DIR@/../include # This tag can be used to specify the character encoding of the source files # that doxygen parses. Internally doxygen uses the UTF-8 encoding, which is # also the default input encoding. Doxygen uses libiconv (or the iconv built # into libc) for the transcoding. See http://www.gnu.org/software/libiconv for # the list of possible encodings. INPUT_ENCODING = UTF-8 # If the value of the INPUT tag contains directories, you can use the # FILE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank the following patterns are tested: # *.c *.cc *.cxx *.cpp *.c++ *.d *.java *.ii *.ixx *.ipp *.i++ *.inl *.h *.hh # *.hxx *.hpp *.h++ *.idl *.odl *.cs *.php *.php3 *.inc *.m *.mm *.dox *.py # *.f90 *.f *.for *.vhd *.vhdl FILE_PATTERNS = # The RECURSIVE tag can be used to turn specify whether or not subdirectories # should be searched for input files as well. Possible values are YES and NO. # If left blank NO is used. RECURSIVE = YES # The EXCLUDE tag can be used to specify files and/or directories that should be # excluded from the INPUT source files. This way you can easily exclude a # subdirectory from a directory tree whose root is specified with the INPUT tag. # Note that relative paths are relative to the directory from which doxygen is # run. EXCLUDE = # The EXCLUDE_SYMLINKS tag can be used to select whether or not files or # directories that are symbolic links (a Unix file system feature) are excluded # from the input. EXCLUDE_SYMLINKS = NO # If the value of the INPUT tag contains directories, you can use the # EXCLUDE_PATTERNS tag to specify one or more wildcard patterns to exclude # certain files from those directories. Note that the wildcards are matched # against the file with absolute path, so to exclude all test directories # for example use the pattern */test/* EXCLUDE_PATTERNS = # The EXCLUDE_SYMBOLS tag can be used to specify one or more symbol names # (namespaces, classes, functions, etc.) that should be excluded from the # output. The symbol name can be a fully qualified name, a word, or if the # wildcard * is used, a substring. Examples: ANamespace, AClass, # AClass::ANamespace, ANamespace::*Test EXCLUDE_SYMBOLS = # The EXAMPLE_PATH tag can be used to specify one or more files or # directories that contain example code fragments that are included (see # the \include command). EXAMPLE_PATH = @CMAKE_CURRENT_SOURCE_DIR@/../tests # If the value of the EXAMPLE_PATH tag contains directories, you can use the # EXAMPLE_PATTERNS tag to specify one or more wildcard pattern (like *.cpp # and *.h) to filter out the source-files in the directories. If left # blank all files are included. EXAMPLE_PATTERNS = # If the EXAMPLE_RECURSIVE tag is set to YES then subdirectories will be # searched for input files to be used with the \include or \dontinclude # commands irrespective of the value of the RECURSIVE tag. # Possible values are YES and NO. If left blank NO is used. EXAMPLE_RECURSIVE = YES # The IMAGE_PATH tag can be used to specify one or more files or # directories that contain image that are included in the documentation (see # the \image command). IMAGE_PATH = # The INPUT_FILTER tag can be used to specify a program that doxygen should # invoke to filter for each input file. Doxygen will invoke the filter program # by executing (via popen()) the command , where # is the value of the INPUT_FILTER tag, and is the name of an # input file. Doxygen will then use the output that the filter program writes # to standard output. # If FILTER_PATTERNS is specified, this tag will be # ignored. INPUT_FILTER = # The FILTER_PATTERNS tag can be used to specify filters on a per file pattern # basis. # Doxygen will compare the file name with each pattern and apply the # filter if there is a match. # The filters are a list of the form: # pattern=filter (like *.cpp=my_cpp_filter). See INPUT_FILTER for further # info on how filters are used. If FILTER_PATTERNS is empty or if # non of the patterns match the file name, INPUT_FILTER is applied. FILTER_PATTERNS = # If the FILTER_SOURCE_FILES tag is set to YES, the input filter (if set using # INPUT_FILTER) will be used to filter the input files when producing source # files to browse (i.e. when SOURCE_BROWSER is set to YES). FILTER_SOURCE_FILES = NO # The FILTER_SOURCE_PATTERNS tag can be used to specify source filters per file # pattern. A pattern will override the setting for FILTER_PATTERN (if any) # and it is also possible to disable source filtering for a specific pattern # using *.ext= (so without naming a filter). This option only has effect when # FILTER_SOURCE_FILES is enabled. FILTER_SOURCE_PATTERNS = # If the USE_MD_FILE_AS_MAINPAGE tag refers to the name of a markdown file that # is part of the input, its contents will be placed on the main page (index.html). # This can be useful if you have a project on for instance GitHub and want reuse # the introduction page also for the doxygen output. USE_MDFILE_AS_MAINPAGE = @CMAKE_SOURCE_DIR@/README.md #--------------------------------------------------------------------------- # configuration options related to source browsing #--------------------------------------------------------------------------- # If the SOURCE_BROWSER tag is set to YES then a list of source files will # be generated. Documented entities will be cross-referenced with these sources. # Note: To get rid of all source code in the generated output, make sure also # VERBATIM_HEADERS is set to NO. SOURCE_BROWSER = YES # Setting the INLINE_SOURCES tag to YES will include the body # of functions and classes directly in the documentation. INLINE_SOURCES = NO # Setting the STRIP_CODE_COMMENTS tag to YES (the default) will instruct # doxygen to hide any special comment blocks from generated source code # fragments. Normal C, C++ and Fortran comments will always remain visible. STRIP_CODE_COMMENTS = YES # If the REFERENCED_BY_RELATION tag is set to YES # then for each documented function all documented # functions referencing it will be listed. REFERENCED_BY_RELATION = YES # If the REFERENCES_RELATION tag is set to YES # then for each documented function all documented entities # called/used by that function will be listed. REFERENCES_RELATION = YES # If the REFERENCES_LINK_SOURCE tag is set to YES (the default) # and SOURCE_BROWSER tag is set to YES, then the hyperlinks from # functions in REFERENCES_RELATION and REFERENCED_BY_RELATION lists will # link to the source code. # Otherwise they will link to the documentation. REFERENCES_LINK_SOURCE = YES # If the USE_HTAGS tag is set to YES then the references to source code # will point to the HTML generated by the htags(1) tool instead of doxygen # built-in source browser. The htags tool is part of GNU's global source # tagging system (see http://www.gnu.org/software/global/global.html). You # will need version 4.8.6 or higher. USE_HTAGS = NO # If the VERBATIM_HEADERS tag is set to YES (the default) then Doxygen # will generate a verbatim copy of the header file for each class for # which an include is specified. Set to NO to disable this. VERBATIM_HEADERS = YES #--------------------------------------------------------------------------- # configuration options related to the alphabetical class index #--------------------------------------------------------------------------- # If the ALPHABETICAL_INDEX tag is set to YES, an alphabetical index # of all compounds will be generated. Enable this if the project # contains a lot of classes, structs, unions or interfaces. ALPHABETICAL_INDEX = YES # If the alphabetical index is enabled (see ALPHABETICAL_INDEX) then # the COLS_IN_ALPHA_INDEX tag can be used to specify the number of columns # in which this list will be split (can be a number in the range [1..20]) COLS_IN_ALPHA_INDEX = 5 # In case all classes in a project start with a common prefix, all # classes will be put under the same header in the alphabetical index. # The IGNORE_PREFIX tag can be used to specify one or more prefixes that # should be ignored while generating the index headers. IGNORE_PREFIX = #--------------------------------------------------------------------------- # configuration options related to the HTML output #--------------------------------------------------------------------------- # If the GENERATE_HTML tag is set to YES (the default) Doxygen will # generate HTML output. GENERATE_HTML = YES # The HTML_OUTPUT tag is used to specify where the HTML docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `html' will be used as the default path. HTML_OUTPUT = html # The HTML_FILE_EXTENSION tag can be used to specify the file extension for # each generated HTML page (for example: .htm,.php,.asp). If it is left blank # doxygen will generate files with .html extension. HTML_FILE_EXTENSION = .html # The HTML_HEADER tag can be used to specify a personal HTML header for # each generated HTML page. If it is left blank doxygen will generate a # standard header. Note that when using a custom header you are responsible # for the proper inclusion of any scripts and style sheets that doxygen # needs, which is dependent on the configuration options used. # It is advised to generate a default header using "doxygen -w html # header.html footer.html stylesheet.css YourConfigFile" and then modify # that header. Note that the header is subject to change so you typically # have to redo this when upgrading to a newer version of doxygen or when # changing the value of configuration settings such as GENERATE_TREEVIEW! HTML_HEADER = # The HTML_FOOTER tag can be used to specify a personal HTML footer for # each generated HTML page. If it is left blank doxygen will generate a # standard footer. HTML_FOOTER = # The HTML_STYLESHEET tag can be used to specify a user-defined cascading # style sheet that is used by each HTML page. It can be used to # fine-tune the look of the HTML output. If left blank doxygen will # generate a default style sheet. Note that it is recommended to use # HTML_EXTRA_STYLESHEET instead of this one, as it is more robust and this # tag will in the future become obsolete. HTML_STYLESHEET = # The HTML_EXTRA_STYLESHEET tag can be used to specify an additional # user-defined cascading style sheet that is included after the standard # style sheets created by doxygen. Using this option one can overrule # certain style aspects. This is preferred over using HTML_STYLESHEET # since it does not replace the standard style sheet and is therefor more # robust against future updates. Doxygen will copy the style sheet file to # the output directory. HTML_EXTRA_STYLESHEET = @CMAKE_CURRENT_SOURCE_DIR@/extra.css # The HTML_EXTRA_FILES tag can be used to specify one or more extra images or # other source files which should be copied to the HTML output directory. Note # that these files will be copied to the base HTML output directory. Use the # $relpath$ marker in the HTML_HEADER and/or HTML_FOOTER files to load these # files. In the HTML_STYLESHEET file, use the file name only. Also note that # the files will be copied as-is; there are no commands or markers available. HTML_EXTRA_FILES = # The HTML_COLORSTYLE_HUE tag controls the color of the HTML output. # Doxygen will adjust the colors in the style sheet and background images # according to this color. Hue is specified as an angle on a colorwheel, # see http://en.wikipedia.org/wiki/Hue for more information. # For instance the value 0 represents red, 60 is yellow, 120 is green, # 180 is cyan, 240 is blue, 300 purple, and 360 is red again. # The allowed range is 0 to 359. HTML_COLORSTYLE_HUE = 220 # The HTML_COLORSTYLE_SAT tag controls the purity (or saturation) of # the colors in the HTML output. For a value of 0 the output will use # grayscales only. A value of 255 will produce the most vivid colors. HTML_COLORSTYLE_SAT = 100 # The HTML_COLORSTYLE_GAMMA tag controls the gamma correction applied to # the luminance component of the colors in the HTML output. Values below # 100 gradually make the output lighter, whereas values above 100 make # the output darker. The value divided by 100 is the actual gamma applied, # so 80 represents a gamma of 0.8, The value 220 represents a gamma of 2.2, # and 100 does not change the gamma. HTML_COLORSTYLE_GAMMA = 80 # If the HTML_TIMESTAMP tag is set to YES then the footer of each generated HTML # page will contain the date and time when the page was generated. Setting # this to NO can help when comparing the output of multiple runs. HTML_TIMESTAMP = YES # If the HTML_DYNAMIC_SECTIONS tag is set to YES then the generated HTML # documentation will contain sections that can be hidden and shown after the # page has loaded. HTML_DYNAMIC_SECTIONS = YES # With HTML_INDEX_NUM_ENTRIES one can control the preferred number of # entries shown in the various tree structured indices initially; the user # can expand and collapse entries dynamically later on. Doxygen will expand # the tree to such a level that at most the specified number of entries are # visible (unless a fully collapsed tree already exceeds this amount). # So setting the number of entries 1 will produce a full collapsed tree by # default. 0 is a special value representing an infinite number of entries # and will result in a full expanded tree by default. HTML_INDEX_NUM_ENTRIES = 100 # If the GENERATE_DOCSET tag is set to YES, additional index files # will be generated that can be used as input for Apple's Xcode 3 # integrated development environment, introduced with OSX 10.5 (Leopard). # To create a documentation set, doxygen will generate a Makefile in the # HTML output directory. Running make will produce the docset in that # directory and running "make install" will install the docset in # ~/Library/Developer/Shared/Documentation/DocSets so that Xcode will find # it at startup. # See http://developer.apple.com/tools/creatingdocsetswithdoxygen.html # for more information. GENERATE_DOCSET = NO # When GENERATE_DOCSET tag is set to YES, this tag determines the name of the # feed. A documentation feed provides an umbrella under which multiple # documentation sets from a single provider (such as a company or product suite) # can be grouped. DOCSET_FEEDNAME = "Doxygen generated docs" # When GENERATE_DOCSET tag is set to YES, this tag specifies a string that # should uniquely identify the documentation set bundle. This should be a # reverse domain-name style string, e.g. com.mycompany.MyDocSet. Doxygen # will append .docset to the name. DOCSET_BUNDLE_ID = org.doxygen.Project # When GENERATE_PUBLISHER_ID tag specifies a string that should uniquely # identify the documentation publisher. This should be a reverse domain-name # style string, e.g. com.mycompany.MyDocSet.documentation. DOCSET_PUBLISHER_ID = org.doxygen.Publisher # The GENERATE_PUBLISHER_NAME tag identifies the documentation publisher. DOCSET_PUBLISHER_NAME = Publisher # If the GENERATE_HTMLHELP tag is set to YES, additional index files # will be generated that can be used as input for tools like the # Microsoft HTML help workshop to generate a compiled HTML help file (.chm) # of the generated HTML documentation. GENERATE_HTMLHELP = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_FILE tag can # be used to specify the file name of the resulting .chm file. You # can add a path in front of the file if the result should not be # written to the html output directory. CHM_FILE = # If the GENERATE_HTMLHELP tag is set to YES, the HHC_LOCATION tag can # be used to specify the location (absolute path including file name) of # the HTML help compiler (hhc.exe). If non-empty doxygen will try to run # the HTML help compiler on the generated index.hhp. HHC_LOCATION = # If the GENERATE_HTMLHELP tag is set to YES, the GENERATE_CHI flag # controls if a separate .chi index file is generated (YES) or that # it should be included in the master .chm file (NO). GENERATE_CHI = NO # If the GENERATE_HTMLHELP tag is set to YES, the CHM_INDEX_ENCODING # is used to encode HtmlHelp index (hhk), content (hhc) and project file # content. CHM_INDEX_ENCODING = # If the GENERATE_HTMLHELP tag is set to YES, the BINARY_TOC flag # controls whether a binary table of contents is generated (YES) or a # normal table of contents (NO) in the .chm file. BINARY_TOC = NO # The TOC_EXPAND flag can be set to YES to add extra items for group members # to the contents of the HTML help documentation and to the tree view. TOC_EXPAND = NO # If the GENERATE_QHP tag is set to YES and both QHP_NAMESPACE and # QHP_VIRTUAL_FOLDER are set, an additional index file will be generated # that can be used as input for Qt's qhelpgenerator to generate a # Qt Compressed Help (.qch) of the generated HTML documentation. GENERATE_QHP = NO # If the QHG_LOCATION tag is specified, the QCH_FILE tag can # be used to specify the file name of the resulting .qch file. # The path specified is relative to the HTML output folder. QCH_FILE = # The QHP_NAMESPACE tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#namespace QHP_NAMESPACE = org.doxygen.Project # The QHP_VIRTUAL_FOLDER tag specifies the namespace to use when generating # Qt Help Project output. For more information please see # http://doc.trolltech.com/qthelpproject.html#virtual-folders QHP_VIRTUAL_FOLDER = doc # If QHP_CUST_FILTER_NAME is set, it specifies the name of a custom filter to # add. For more information please see # http://doc.trolltech.com/qthelpproject.html#custom-filters QHP_CUST_FILTER_NAME = # The QHP_CUST_FILT_ATTRS tag specifies the list of the attributes of the # custom filter to add. For more information please see # # Qt Help Project / Custom Filters. QHP_CUST_FILTER_ATTRS = # The QHP_SECT_FILTER_ATTRS tag specifies the list of the attributes this # project's # filter section matches. # # Qt Help Project / Filter Attributes. QHP_SECT_FILTER_ATTRS = # If the GENERATE_QHP tag is set to YES, the QHG_LOCATION tag can # be used to specify the location of Qt's qhelpgenerator. # If non-empty doxygen will try to run qhelpgenerator on the generated # .qhp file. QHG_LOCATION = # If the GENERATE_ECLIPSEHELP tag is set to YES, additional index files # will be generated, which together with the HTML files, form an Eclipse help # plugin. To install this plugin and make it available under the help contents # menu in Eclipse, the contents of the directory containing the HTML and XML # files needs to be copied into the plugins directory of eclipse. The name of # the directory within the plugins directory should be the same as # the ECLIPSE_DOC_ID value. After copying Eclipse needs to be restarted before # the help appears. GENERATE_ECLIPSEHELP = NO # A unique identifier for the eclipse help plugin. When installing the plugin # the directory name containing the HTML and XML files should also have # this name. ECLIPSE_DOC_ID = org.doxygen.Project # The DISABLE_INDEX tag can be used to turn on/off the condensed index (tabs) # at top of each HTML page. The value NO (the default) enables the index and # the value YES disables it. Since the tabs have the same information as the # navigation tree you can set this option to NO if you already set # GENERATE_TREEVIEW to YES. DISABLE_INDEX = YES # The GENERATE_TREEVIEW tag is used to specify whether a tree-like index # structure should be generated to display hierarchical information. # If the tag value is set to YES, a side panel will be generated # containing a tree-like index structure (just like the one that # is generated for HTML Help). For this to work a browser that supports # JavaScript, DHTML, CSS and frames is required (i.e. any modern browser). # Windows users are probably better off using the HTML help feature. # Since the tree basically has the same information as the tab index you # could consider to set DISABLE_INDEX to NO when enabling this option. GENERATE_TREEVIEW = YES # The ENUM_VALUES_PER_LINE tag can be used to set the number of enum values # (range [0,1..20]) that doxygen will group on one line in the generated HTML # documentation. Note that a value of 0 will completely suppress the enum # values from appearing in the overview section. ENUM_VALUES_PER_LINE = 1 # If the treeview is enabled (see GENERATE_TREEVIEW) then this tag can be # used to set the initial width (in pixels) of the frame in which the tree # is shown. TREEVIEW_WIDTH = 250 # When the EXT_LINKS_IN_WINDOW option is set to YES doxygen will open # links to external symbols imported via tag files in a separate window. EXT_LINKS_IN_WINDOW = NO # Use this tag to change the font size of Latex formulas included # as images in the HTML documentation. The default is 10. Note that # when you change the font size after a successful doxygen run you need # to manually remove any form_*.png images from the HTML output directory # to force them to be regenerated. FORMULA_FONTSIZE = 10 # Use the FORMULA_TRANPARENT tag to determine whether or not the images # generated for formulas are transparent PNGs. Transparent PNGs are # not supported properly for IE 6.0, but are supported on all modern browsers. # Note that when changing this option you need to delete any form_*.png files # in the HTML output before the changes have effect. FORMULA_TRANSPARENT = YES # Enable the USE_MATHJAX option to render LaTeX formulas using MathJax # (see http://www.mathjax.org) which uses client side Javascript for the # rendering instead of using prerendered bitmaps. Use this if you do not # have LaTeX installed or if you want to formulas look prettier in the HTML # output. When enabled you may also need to install MathJax separately and # configure the path to it using the MATHJAX_RELPATH option. USE_MATHJAX = NO # When MathJax is enabled you can set the default output format to be used for # thA MathJax output. Supported types are HTML-CSS, NativeMML (i.e. MathML) and # SVG. The default value is HTML-CSS, which is slower, but has the best # compatibility. MATHJAX_FORMAT = HTML-CSS # When MathJax is enabled you need to specify the location relative to the # HTML output directory using the MATHJAX_RELPATH option. The destination # directory should contain the MathJax.js script. For instance, if the mathjax # directory is located at the same level as the HTML output directory, then # MATHJAX_RELPATH should be ../mathjax. The default value points to # the MathJax Content Delivery Network so you can quickly see the result without # installing MathJax. # However, it is strongly recommended to install a local # copy of MathJax from http://www.mathjax.org before deployment. MATHJAX_RELPATH = http://cdn.mathjax.org/mathjax/latest # The MATHJAX_EXTENSIONS tag can be used to specify one or MathJax extension # names that should be enabled during MathJax rendering. MATHJAX_EXTENSIONS = # When the SEARCHENGINE tag is enabled doxygen will generate a search box # for the HTML output. The underlying search engine uses javascript # and DHTML and should work on any modern browser. Note that when using # HTML help (GENERATE_HTMLHELP), Qt help (GENERATE_QHP), or docsets # (GENERATE_DOCSET) there is already a search function so this one should # typically be disabled. For large projects the javascript based search engine # can be slow, then enabling SERVER_BASED_SEARCH may provide a better solution. SEARCHENGINE = NO # When the SERVER_BASED_SEARCH tag is enabled the search engine will be # implemented using a web server instead of a web client using Javascript. # There are two flavours of web server based search depending on the # EXTERNAL_SEARCH setting. When disabled, doxygen will generate a PHP script for # searching and an index file used by the script. When EXTERNAL_SEARCH is # enabled the indexing and searching needs to be provided by external tools. # See the manual for details. SERVER_BASED_SEARCH = NO # When EXTERNAL_SEARCH is enabled doxygen will no longer generate the PHP # script for searching. Instead the search results are written to an XML file # which needs to be processed by an external indexer. Doxygen will invoke an # external search engine pointed to by the SEARCHENGINE_URL option to obtain # the search results. Doxygen ships with an example indexer (doxyindexer) and # search engine (doxysearch.cgi) which are based on the open source search engine # library Xapian. See the manual for configuration details. EXTERNAL_SEARCH = NO # The SEARCHENGINE_URL should point to a search engine hosted by a web server # which will returned the search results when EXTERNAL_SEARCH is enabled. # Doxygen ships with an example search engine (doxysearch) which is based on # the open source search engine library Xapian. See the manual for configuration # details. SEARCHENGINE_URL = # When SERVER_BASED_SEARCH and EXTERNAL_SEARCH are both enabled the unindexed # search data is written to a file for indexing by an external tool. With the # SEARCHDATA_FILE tag the name of this file can be specified. SEARCHDATA_FILE = searchdata.xml # When SERVER_BASED_SEARCH AND EXTERNAL_SEARCH are both enabled the # EXTERNAL_SEARCH_ID tag can be used as an identifier for the project. This is # useful in combination with EXTRA_SEARCH_MAPPINGS to search through multiple # projects and redirect the results back to the right project. EXTERNAL_SEARCH_ID = # The EXTRA_SEARCH_MAPPINGS tag can be used to enable searching through doxygen # projects other than the one defined by this configuration file, but that are # all added to the same external search index. Each project needs to have a # unique id set via EXTERNAL_SEARCH_ID. The search mapping then maps the id # of to a relative location where the documentation can be found. # The format is: EXTRA_SEARCH_MAPPINGS = id1=loc1 id2=loc2 ... EXTRA_SEARCH_MAPPINGS = #--------------------------------------------------------------------------- # configuration options related to the LaTeX output #--------------------------------------------------------------------------- # If the GENERATE_LATEX tag is set to YES (the default) Doxygen will # generate Latex output. GENERATE_LATEX = YES # The LATEX_OUTPUT tag is used to specify where the LaTeX docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `latex' will be used as the default path. LATEX_OUTPUT = latex # The LATEX_CMD_NAME tag can be used to specify the LaTeX command name to be # invoked. If left blank `latex' will be used as the default command name. # Note that when enabling USE_PDFLATEX this option is only used for # generating bitmaps for formulas in the HTML output, but not in the # Makefile that is written to the output directory. LATEX_CMD_NAME = latex # The MAKEINDEX_CMD_NAME tag can be used to specify the command name to # generate index for LaTeX. If left blank `makeindex' will be used as the # default command name. MAKEINDEX_CMD_NAME = makeindex # If the COMPACT_LATEX tag is set to YES Doxygen generates more compact # LaTeX documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_LATEX = YES # The PAPER_TYPE tag can be used to set the paper type that is used # by the printer. Possible values are: a4, letter, legal and # executive. If left blank a4wide will be used. PAPER_TYPE = a4 # The EXTRA_PACKAGES tag can be to specify one or more names of LaTeX # packages that should be included in the LaTeX output. EXTRA_PACKAGES = # The LATEX_HEADER tag can be used to specify a personal LaTeX header for # the generated latex document. The header should contain everything until # the first chapter. If it is left blank doxygen will generate a # standard header. Notice: only use this tag if you know what you are doing! LATEX_HEADER = # The LATEX_FOOTER tag can be used to specify a personal LaTeX footer for # the generated latex document. The footer should contain everything after # the last chapter. If it is left blank doxygen will generate a # standard footer. Notice: only use this tag if you know what you are doing! LATEX_FOOTER = # If the PDF_HYPERLINKS tag is set to YES, the LaTeX that is generated # is prepared for conversion to pdf (using ps2pdf). The pdf file will # contain links (just like the HTML output) instead of page references # This makes the output suitable for online browsing using a pdf viewer. PDF_HYPERLINKS = YES # If the USE_PDFLATEX tag is set to YES, pdflatex will be used instead of # plain latex in the generated Makefile. Set this option to YES to get a # higher quality PDF documentation. USE_PDFLATEX = YES # If the LATEX_BATCHMODE tag is set to YES, doxygen will add the \\batchmode. # command to the generated LaTeX files. This will instruct LaTeX to keep # running if errors occur, instead of asking the user for help. # This option is also used when generating formulas in HTML. LATEX_BATCHMODE = NO # If LATEX_HIDE_INDICES is set to YES then doxygen will not # include the index chapters (such as File Index, Compound Index, etc.) # in the output. LATEX_HIDE_INDICES = NO # If LATEX_SOURCE_CODE is set to YES then doxygen will include # source code with syntax highlighting in the LaTeX output. # Note that which sources are shown also depends on other settings # such as SOURCE_BROWSER. LATEX_SOURCE_CODE = NO # The LATEX_BIB_STYLE tag can be used to specify the style to use for the # bibliography, e.g. plainnat, or ieeetr. The default style is "plain". See # http://en.wikipedia.org/wiki/BibTeX for more info. LATEX_BIB_STYLE = plain #--------------------------------------------------------------------------- # configuration options related to the RTF output #--------------------------------------------------------------------------- # If the GENERATE_RTF tag is set to YES Doxygen will generate RTF output # The RTF output is optimized for Word 97 and may not look very pretty with # other RTF readers or editors. GENERATE_RTF = NO # The RTF_OUTPUT tag is used to specify where the RTF docs will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `rtf' will be used as the default path. RTF_OUTPUT = rtf # If the COMPACT_RTF tag is set to YES Doxygen generates more compact # RTF documents. This may be useful for small projects and may help to # save some trees in general. COMPACT_RTF = NO # If the RTF_HYPERLINKS tag is set to YES, the RTF that is generated # will contain hyperlink fields. The RTF file will # contain links (just like the HTML output) instead of page references. # This makes the output suitable for online browsing using WORD or other # programs which support those fields. # Note: wordpad (write) and others do not support links. RTF_HYPERLINKS = NO # Load style sheet definitions from file. Syntax is similar to doxygen's # config file, i.e. a series of assignments. You only have to provide # replacements, missing definitions are set to their default value. RTF_STYLESHEET_FILE = # Set optional variables used in the generation of an rtf document. # Syntax is similar to doxygen's config file. RTF_EXTENSIONS_FILE = #--------------------------------------------------------------------------- # configuration options related to the man page output #--------------------------------------------------------------------------- # If the GENERATE_MAN tag is set to YES (the default) Doxygen will # generate man pages GENERATE_MAN = YES # The MAN_OUTPUT tag is used to specify where the man pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `man' will be used as the default path. MAN_OUTPUT = man # The MAN_EXTENSION tag determines the extension that is added to # the generated man pages (default is the subroutine's section .3) MAN_EXTENSION = .3 # If the MAN_LINKS tag is set to YES and Doxygen generates man output, # then it will generate one additional man file for each entity # documented in the real man page(s). These additional files # only source the real man page, but without them the man command # would be unable to find the correct page. The default is NO. MAN_LINKS = NO #--------------------------------------------------------------------------- # configuration options related to the XML output #--------------------------------------------------------------------------- # If the GENERATE_XML tag is set to YES Doxygen will # generate an XML file that captures the structure of # the code including all documentation. GENERATE_XML = NO # The XML_OUTPUT tag is used to specify where the XML pages will be put. # If a relative path is entered the value of OUTPUT_DIRECTORY will be # put in front of it. If left blank `xml' will be used as the default path. XML_OUTPUT = xml # The XML_SCHEMA tag can be used to specify an XML schema, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_SCHEMA = # The XML_DTD tag can be used to specify an XML DTD, # which can be used by a validating XML parser to check the # syntax of the XML files. XML_DTD = # If the XML_PROGRAMLISTING tag is set to YES Doxygen will # dump the program listings (including syntax highlighting # and cross-referencing information) to the XML output. Note that # enabling this will significantly increase the size of the XML output. XML_PROGRAMLISTING = YES #--------------------------------------------------------------------------- # configuration options for the AutoGen Definitions output #--------------------------------------------------------------------------- # If the GENERATE_AUTOGEN_DEF tag is set to YES Doxygen will # generate an AutoGen Definitions (see autogen.sf.net) file # that captures the structure of the code including all # documentation. Note that this feature is still experimental # and incomplete at the moment. GENERATE_AUTOGEN_DEF = NO #--------------------------------------------------------------------------- # configuration options related to the Perl module output #--------------------------------------------------------------------------- # If the GENERATE_PERLMOD tag is set to YES Doxygen will # generate a Perl module file that captures the structure of # the code including all documentation. Note that this # feature is still experimental and incomplete at the # moment. GENERATE_PERLMOD = NO # If the PERLMOD_LATEX tag is set to YES Doxygen will generate # the necessary Makefile rules, Perl scripts and LaTeX code to be able # to generate PDF and DVI output from the Perl module output. PERLMOD_LATEX = NO # If the PERLMOD_PRETTY tag is set to YES the Perl module output will be # nicely formatted so it can be parsed by a human reader. # This is useful # if you want to understand what is going on. # On the other hand, if this # tag is set to NO the size of the Perl module output will be much smaller # and Perl will parse it just the same. PERLMOD_PRETTY = YES # The names of the make variables in the generated doxyrules.make file # are prefixed with the string contained in PERLMOD_MAKEVAR_PREFIX. # This is useful so different doxyrules.make files included by the same # Makefile don't overwrite each other's variables. PERLMOD_MAKEVAR_PREFIX = #--------------------------------------------------------------------------- # Configuration options related to the preprocessor #--------------------------------------------------------------------------- # If the ENABLE_PREPROCESSING tag is set to YES (the default) Doxygen will # evaluate all C-preprocessor directives found in the sources and include # files. ENABLE_PREPROCESSING = YES # If the MACRO_EXPANSION tag is set to YES Doxygen will expand all macro # names in the source code. If set to NO (the default) only conditional # compilation will be performed. Macro expansion can be done in a controlled # way by setting EXPAND_ONLY_PREDEF to YES. MACRO_EXPANSION = NO # If the EXPAND_ONLY_PREDEF and MACRO_EXPANSION tags are both set to YES # then the macro expansion is limited to the macros specified with the # PREDEFINED and EXPAND_AS_DEFINED tags. EXPAND_ONLY_PREDEF = NO # If the SEARCH_INCLUDES tag is set to YES (the default) the includes files # pointed to by INCLUDE_PATH will be searched when a #include is found. SEARCH_INCLUDES = YES # The INCLUDE_PATH tag can be used to specify one or more directories that # contain include files that are not input files but should be processed by # the preprocessor. INCLUDE_PATH = # You can use the INCLUDE_FILE_PATTERNS tag to specify one or more wildcard # patterns (like *.h and *.hpp) to filter out the header-files in the # directories. If left blank, the patterns specified with FILE_PATTERNS will # be used. INCLUDE_FILE_PATTERNS = # The PREDEFINED tag can be used to specify one or more macro names that # are defined before the preprocessor is started (similar to the -D option of # gcc). The argument of the tag is a list of macros of the form: name # or name=definition (no spaces). If the definition and the = are # omitted =1 is assumed. To prevent a macro definition from being # undefined via #undef or recursively expanded use the := operator # instead of the = operator. PREDEFINED = # If the MACRO_EXPANSION and EXPAND_ONLY_PREDEF tags are set to YES then # this tag can be used to specify a list of macro names that should be expanded. # The macro definition that is found in the sources will be used. # Use the PREDEFINED tag if you want to use a different macro definition that # overrules the definition found in the source code. EXPAND_AS_DEFINED = # If the SKIP_FUNCTION_MACROS tag is set to YES (the default) then # doxygen's preprocessor will remove all references to function-like macros # that are alone on a line, have an all uppercase name, and do not end with a # semicolon, because these will confuse the parser if not removed. SKIP_FUNCTION_MACROS = YES #--------------------------------------------------------------------------- # Configuration::additions related to external references #--------------------------------------------------------------------------- # The TAGFILES option can be used to specify one or more tagfiles. For each # tag file the location of the external documentation should be added. The # format of a tag file without this location is as follows: # # TAGFILES = file1 file2 ... # Adding location for the tag files is done as follows: # # TAGFILES = file1=loc1 "file2 = loc2" ... # where "loc1" and "loc2" can be relative or absolute paths # or URLs. Note that each tag file must have a unique name (where the name does # NOT include the path). If a tag file is not located in the directory in which # doxygen is run, you must also specify the path to the tagfile here. TAGFILES = # When a file name is specified after GENERATE_TAGFILE, doxygen will create # a tag file that is based on the input files it reads. GENERATE_TAGFILE = # If the ALLEXTERNALS tag is set to YES all external classes will be listed # in the class index. If set to NO only the inherited external classes # will be listed. ALLEXTERNALS = NO # If the EXTERNAL_GROUPS tag is set to YES all external groups will be listed # in the modules index. If set to NO, only the current project's groups will # be listed. EXTERNAL_GROUPS = YES # The PERL_PATH should be the absolute path and name of the perl script # interpreter (i.e. the result of `which perl'). PERL_PATH = /usr/bin/perl #--------------------------------------------------------------------------- # Configuration options related to the dot tool #--------------------------------------------------------------------------- # If the CLASS_DIAGRAMS tag is set to YES (the default) Doxygen will # generate a inheritance diagram (in HTML, RTF and LaTeX) for classes with base # or super classes. Setting the tag to NO turns the diagrams off. Note that # this option also works with HAVE_DOT disabled, but it is recommended to # install and use dot, since it yields more powerful graphs. CLASS_DIAGRAMS = YES # You can define message sequence charts within doxygen comments using the \msc # command. Doxygen will then run the mscgen tool (see # http://www.mcternan.me.uk/mscgen/) to produce the chart and insert it in the # documentation. The MSCGEN_PATH tag allows you to specify the directory where # the mscgen tool resides. If left empty the tool is assumed to be found in the # default search path. MSCGEN_PATH = # If set to YES, the inheritance and collaboration graphs will hide # inheritance and usage relations if the target is undocumented # or is not a class. HIDE_UNDOC_RELATIONS = NO # If you set the HAVE_DOT tag to YES then doxygen will assume the dot tool is # available from the path. This tool is part of Graphviz, a graph visualization # toolkit from AT&T and Lucent Bell Labs. The other options in this section # have no effect if this option is set to NO (the default) HAVE_DOT = YES # The DOT_NUM_THREADS specifies the number of dot invocations doxygen is # allowed to run in parallel. When set to 0 (the default) doxygen will # base this on the number of processors available in the system. You can set it # explicitly to a value larger than 0 to get control over the balance # between CPU load and processing speed. DOT_NUM_THREADS = 1 # By default doxygen will use the Helvetica font for all dot files that # doxygen generates. When you want a differently looking font you can specify # the font name using DOT_FONTNAME. You need to make sure dot is able to find # the font, which can be done by putting it in a standard location or by setting # the DOTFONTPATH environment variable or by setting DOT_FONTPATH to the # directory containing the font. DOT_FONTNAME = Helvetica # The DOT_FONTSIZE tag can be used to set the size of the font of dot graphs. # The default size is 10pt. DOT_FONTSIZE = 10 # By default doxygen will tell dot to use the Helvetica font. # If you specify a different font using DOT_FONTNAME you can use DOT_FONTPATH to # set the path where dot can find it. DOT_FONTPATH = # If the CLASS_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect inheritance relations. Setting this tag to YES will force the # CLASS_DIAGRAMS tag to NO. CLASS_GRAPH = YES # If the COLLABORATION_GRAPH and HAVE_DOT tags are set to YES then doxygen # will generate a graph for each documented class showing the direct and # indirect implementation dependencies (inheritance, containment, and # class references variables) of the class with other documented classes. COLLABORATION_GRAPH = YES # If the GROUP_GRAPHS and HAVE_DOT tags are set to YES then doxygen # will generate a graph for groups, showing the direct groups dependencies GROUP_GRAPHS = YES # If the UML_LOOK tag is set to YES doxygen will generate inheritance and # collaboration diagrams in a style similar to the OMG's Unified Modeling # Language. UML_LOOK = YES # If the UML_LOOK tag is enabled, the fields and methods are shown inside # the class node. If there are many fields or methods and many nodes the # graph may become too big to be useful. The UML_LIMIT_NUM_FIELDS # threshold limits the number of items for each type to make the size more # managable. Set this to 0 for no limit. Note that the threshold may be # exceeded by 50% before the limit is enforced. UML_LIMIT_NUM_FIELDS = 10 # If set to YES, the inheritance and collaboration graphs will show the # relations between templates and their instances. TEMPLATE_RELATIONS = NO # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDE_GRAPH, and HAVE_DOT # tags are set to YES then doxygen will generate a graph for each documented # file showing the direct and indirect include dependencies of the file with # other documented files. INCLUDE_GRAPH = YES # If the ENABLE_PREPROCESSING, SEARCH_INCLUDES, INCLUDED_BY_GRAPH, and # HAVE_DOT tags are set to YES then doxygen will generate a graph for each # documented header file showing the documented files that directly or # indirectly include this file. INCLUDED_BY_GRAPH = YES # If the CALL_GRAPH and HAVE_DOT options are set to YES then # doxygen will generate a call dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable call graphs # for selected functions only using the \callgraph command. CALL_GRAPH = YES # If the CALLER_GRAPH and HAVE_DOT tags are set to YES then # doxygen will generate a caller dependency graph for every global function # or class method. Note that enabling this option will significantly increase # the time of a run. So in most cases it will be better to enable caller # graphs for selected functions only using the \callergraph command. CALLER_GRAPH = NO # If the GRAPHICAL_HIERARCHY and HAVE_DOT tags are set to YES then doxygen # will generate a graphical hierarchy of all classes instead of a textual one. GRAPHICAL_HIERARCHY = YES # If the DIRECTORY_GRAPH and HAVE_DOT tags are set to YES # then doxygen will show the dependencies a directory has on other directories # in a graphical way. The dependency relations are determined by the #include # relations between the files in the directories. DIRECTORY_GRAPH = YES # The DOT_IMAGE_FORMAT tag can be used to set the image format of the images # generated by dot. Possible values are svg, png, jpg, or gif. # If left blank png will be used. If you choose svg you need to set # HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible in IE 9+ (other browsers do not have this requirement). DOT_IMAGE_FORMAT = png # If DOT_IMAGE_FORMAT is set to svg, then this option can be set to YES to # enable generation of interactive SVG images that allow zooming and panning. # Note that this requires a modern browser other than Internet Explorer. # Tested and working are Firefox, Chrome, Safari, and Opera. For IE 9+ you # need to set HTML_FILE_EXTENSION to xhtml in order to make the SVG files # visible. Older versions of IE do not have SVG support. INTERACTIVE_SVG = YES # The tag DOT_PATH can be used to specify the path where the dot tool can be # found. If left blank, it is assumed the dot tool can be found in the path. DOT_PATH = # The DOTFILE_DIRS tag can be used to specify one or more directories that # contain dot files that are included in the documentation (see the # \dotfile command). DOTFILE_DIRS = # The MSCFILE_DIRS tag can be used to specify one or more directories that # contain msc files that are included in the documentation (see the # \mscfile command). MSCFILE_DIRS = # The DOT_GRAPH_MAX_NODES tag can be used to set the maximum number of # nodes that will be shown in the graph. If the number of nodes in a graph # becomes larger than this value, doxygen will truncate the graph, which is # visualized by representing a node as a red box. Note that doxygen if the # number of direct children of the root node in a graph is already larger than # DOT_GRAPH_MAX_NODES then the graph will not be shown at all. Also note # that the size of a graph can be further restricted by MAX_DOT_GRAPH_DEPTH. DOT_GRAPH_MAX_NODES = 50 # The MAX_DOT_GRAPH_DEPTH tag can be used to set the maximum depth of the # graphs generated by dot. A depth value of 3 means that only nodes reachable # from the root by following a path via at most 3 edges will be shown. Nodes # that lay further from the root node will be omitted. Note that setting this # option to 1 or 2 may greatly reduce the computation time needed for large # code bases. Also note that the size of a graph can be further restricted by # DOT_GRAPH_MAX_NODES. Using a depth of 0 means no depth restriction. MAX_DOT_GRAPH_DEPTH = 0 # Set the DOT_TRANSPARENT tag to YES to generate images with a transparent # background. This is disabled by default, because dot on Windows does not # seem to support this out of the box. Warning: Depending on the platform used, # enabling this option may lead to badly anti-aliased labels on the edges of # a graph (i.e. they become hard to read). DOT_TRANSPARENT = YES # Set the DOT_MULTI_TARGETS tag to YES allow dot to generate multiple output # files in one run (i.e. multiple -o and -T options on the command line). This # makes dot run faster, but since only newer versions of dot (>1.8.10) # support this, this feature is disabled by default. DOT_MULTI_TARGETS = YES # If the GENERATE_LEGEND tag is set to YES (the default) Doxygen will # generate a legend page explaining the meaning of the various boxes and # arrows in the dot generated graphs. GENERATE_LEGEND = YES # If the DOT_CLEANUP tag is set to YES (the default) Doxygen will # remove the intermediate dot files that are used to generate # the various graphs. DOT_CLEANUP = YES process-cpp-1.0.0+14.04.20140328/doc/CMakeLists.txt0000644000015201777760000000333012315241606021652 0ustar pbusernogroup00000000000000# 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 option( PROCESS_CPP_ENABLE_DOC_GENERATION "Generate package documentation with doxygen" ON ) string(TOLOWER "${CMAKE_BUILD_TYPE}" cmake_build_type_lower) if("${cmake_build_type_lower}" STREQUAL "debug") option( PROCESS_CPP_ENABLE_DOC_GENERATION_BY_DEFAULT "Generate package by default" OFF ) else() option( PROCESS_CPP_ENABLE_DOC_GENERATION_BY_DEFAULT "Generate package by default" ON ) endif() if (PROCESS_CPP_ENABLE_DOC_GENERATION) if (${PROCESS_CPP_ENABLE_DOC_GENERATION_BY_DEFAULT}) set (IS_ALL ALL) endif () find_package(Doxygen) if (DOXYGEN_FOUND) configure_file( ${CMAKE_CURRENT_SOURCE_DIR}/Doxyfile.in ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile @ONLY) add_custom_target(doc ${IS_ALL} ${DOXYGEN_EXECUTABLE} ${CMAKE_CURRENT_BINARY_DIR}/Doxyfile WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR} COMMENT "Generating API documentation with Doxygen" VERBATIM) install( DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html DESTINATION ${CMAKE_INSTALL_DOCDIR}) endif (DOXYGEN_FOUND) endif (PROCESS_CPP_ENABLE_DOC_GENERATION) process-cpp-1.0.0+14.04.20140328/src/0000755000015201777760000000000012315242015017130 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/src/core/0000755000015201777760000000000012315242015020060 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/src/core/testing/0000755000015201777760000000000012315242015021535 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/src/core/testing/cross_process_sync.cpp0000644000015201777760000000553712315241606026203 0ustar pbusernogroup00000000000000/* * 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 */ #include #include #include #include namespace { const int read_fd = 0; const int write_fd = 1; } core::testing::CrossProcessSync::CrossProcessSync() : counter(0) { if (::pipe(fds) < 0) throw std::system_error(errno, std::system_category()); } core::testing::CrossProcessSync::CrossProcessSync(const CrossProcessSync& rhs) : counter(rhs.counter) { fds[0] = ::dup(rhs.fds[0]); fds[1] = ::dup(rhs.fds[1]); } core::testing::CrossProcessSync::~CrossProcessSync() noexcept { ::close(fds[0]); ::close(fds[1]); } core::testing::CrossProcessSync& core::testing::CrossProcessSync::operator=(const core::testing::CrossProcessSync& rhs) { ::close(fds[0]); ::close(fds[1]); fds[0] = ::dup(rhs.fds[0]); fds[1] = ::dup(rhs.fds[1]); counter = rhs.counter; return *this; } void core::testing::CrossProcessSync::try_signal_ready_for(const std::chrono::milliseconds& duration) { static const short empty_revents = 0; pollfd poll_fd[1] = { { fds[write_fd], POLLOUT, empty_revents } }; int rc = -1; if ((rc = ::poll(poll_fd, 1, duration.count())) < 0) throw std::system_error(errno, std::system_category()); else if (rc == 0) throw Error::Timeout{}; static const std::uint32_t value = 1; if (sizeof(value) != write(fds[write_fd], std::addressof(value), sizeof(value))) throw std::system_error(errno, std::system_category()); } std::uint32_t core::testing::CrossProcessSync::wait_for_signal_ready_for(const std::chrono::milliseconds& duration) { static const short empty_revents = 0; pollfd poll_fd[1] = { { fds[read_fd], POLLIN, empty_revents } }; int rc = -1; if ((rc = ::poll(poll_fd, 1, duration.count())) < 0) throw std::system_error(errno, std::system_category()); else if (rc == 0) throw Error::Timeout{}; std::uint32_t value = 0; if (sizeof(value) != read(fds[read_fd], std::addressof(value), sizeof(value))) throw std::system_error(errno, std::system_category()); if (value != 1) throw std::system_error(errno, std::system_category()); counter += value; return counter; } process-cpp-1.0.0+14.04.20140328/src/core/testing/fork_and_run.cpp0000644000015201777760000000556312315241606024726 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include core::testing::ForkAndRunResult core::testing::operator|( core::testing::ForkAndRunResult lhs, core::testing::ForkAndRunResult rhs) { return static_cast( static_cast (lhs) | static_cast(rhs)); } core::testing::ForkAndRunResult core::testing::operator&( core::testing::ForkAndRunResult lhs, core::testing::ForkAndRunResult rhs) { return static_cast( static_cast (lhs) & static_cast(rhs)); } core::testing::ForkAndRunResult core::testing::fork_and_run( const std::function& service, const std::function& client) { core::testing::ForkAndRunResult result = core::testing::ForkAndRunResult::empty; auto service_process = core::posix::fork(service, core::posix::StandardStream::empty); auto client_process = core::posix::fork(client, core::posix::StandardStream::empty); auto client_result = client_process.wait_for(core::posix::wait::Flags::untraced); switch (client_result.status) { case core::posix::wait::Result::Status::exited: if (client_result.detail.if_exited.status == core::posix::exit::Status::failure) result = result | core::testing::ForkAndRunResult::client_failed; break; default: result = result | core::testing::ForkAndRunResult::client_failed; break; } service_process.send_signal_or_throw(core::posix::Signal::sig_term); auto service_result = service_process.wait_for(core::posix::wait::Flags::untraced); switch (service_result.status) { case core::posix::wait::Result::Status::exited: if (service_result.detail.if_exited.status == core::posix::exit::Status::failure) result = result | core::testing::ForkAndRunResult::service_failed; break; default: result = result | core::testing::ForkAndRunResult::service_failed; break; } return result; } process-cpp-1.0.0+14.04.20140328/src/core/posix/0000755000015201777760000000000012315242015021222 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/src/core/posix/child_process.cpp0000644000015201777760000002437212315241615024564 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include #include #include #include #include #include #include #include #include namespace io = boost::iostreams; namespace { struct DeathObserverImpl : public core::posix::ChildProcess::DeathObserver { DeathObserverImpl(const std::shared_ptr& trap) : on_sig_child_connection { trap->signal_raised().connect([this](core::posix::Signal signal) { switch (signal) { case core::posix::Signal::sig_chld: on_sig_child(); break; default: break; } }) } { if (!trap->has(core::posix::Signal::sig_chld)) throw std::logic_error( "DeathObserver::DeathObserverImpl: Given SignalTrap" " instance does not trap Signal::sig_chld."); } bool add(const core::posix::ChildProcess& process) override { if (process.pid() == -1) return false; std::lock_guard lg(guard); bool added = false; auto new_process = std::make_pair(process.pid(), process); std::tie(std::ignore, added) = children.insert(new_process); if (added) { // The process may have died between it's instantiation and it // being added to the children map. Check that it's still alive. int status{-1}; if (::waitpid(process.pid(), &status, WNOHANG) != 0) // child no longer alive { // we missed the SIGCHLD signal so we must now manually // inform our subscribers. signals.child_died(new_process.second); children.erase(new_process.first); return false; } } return added; } bool has(const core::posix::ChildProcess& process) const override { std::lock_guard lg(guard); return children.count(process.pid()) > 0; } const core::Signal& child_died() const override { return signals.child_died; } void on_sig_child() override { pid_t pid{-1}; int status{-1}; while (true) { pid = ::waitpid(0, &status, WNOHANG); if (pid == -1) { if (errno == ECHILD) { break; // No more children } continue; // Ignore stray SIGCHLD signals } else if (pid == 0) { break; // No more children } else { std::lock_guard lg(guard); auto it = children.find(pid); if (it != children.end()) { if (WIFSIGNALED(status) || WIFEXITED(status)) { signals.child_died(it->second); children.erase(it); } } } } } mutable std::mutex guard; std::unordered_map children; core::ScopedConnection on_sig_child_connection; struct { core::Signal child_died; } signals; }; } std::unique_ptr core::posix::ChildProcess::DeathObserver::create_once_with_signal_trap( std::shared_ptr trap) { static std::atomic has_been_created_once{false}; if (has_been_created_once.exchange(true)) throw std::runtime_error { "DeathObserver::create_once_with_signal_trap: " "Cannot create more than one instance." }; try { std::unique_ptr result { new DeathObserverImpl{trap} }; return result; } catch(...) { // We make sure that a throwing c'tor does not impact our ability to // retry creation of a DeathObserver instance. has_been_created_once.store(false); std::rethrow_exception(std::current_exception()); } assert(false && "We should never reach here."); // Silence the compiler. return std::unique_ptr{}; } namespace core { namespace posix { ChildProcess::Pipe ChildProcess::Pipe::invalid() { static Pipe p; static std::once_flag flag; std::call_once(flag, [&]() { p.close_read_fd(); p.close_write_fd(); }); return p; } ChildProcess::Pipe::Pipe() { int rc = ::pipe(fds); if (rc == -1) throw std::system_error(errno, std::system_category()); } ChildProcess::Pipe::Pipe(const ChildProcess::Pipe& rhs) : fds{-1, -1} { if (rhs.fds[0] != -1) fds[0] = ::dup(rhs.fds[0]); if (rhs.fds[1] != -1) fds[1] = ::dup(rhs.fds[1]); } ChildProcess::Pipe::~Pipe() { if (fds[0] != -1) ::close(fds[0]); if (fds[1] != -1) ::close(fds[1]); } int ChildProcess::Pipe::read_fd() const { return fds[0]; } void ChildProcess::Pipe::close_read_fd() { if (fds[0] != -1) { ::close(fds[0]); fds[0] = -1; } } int ChildProcess::Pipe::write_fd() const { return fds[1]; } void ChildProcess::Pipe::close_write_fd() { if (fds[1] != -1) { ::close(fds[1]); fds[1] = -1; } } ChildProcess::Pipe& ChildProcess::Pipe::operator=(const ChildProcess::Pipe& rhs) { if (fds[0] != -1) ::close(fds[0]); if (fds[1] != -1) ::close(fds[1]); if (rhs.fds[0] != -1) fds[0] = ::dup(rhs.fds[0]); else fds[0] = -1; if (rhs.fds[1] != -1) fds[1] = ::dup(rhs.fds[1]); else fds[1] = -1; return *this; } struct ChildProcess::Private { // stdin and stdout are always "relative" to the childprocess, i.e., we // write to stdin of the child process and read from its stdout. Private(pid_t pid, const ChildProcess::Pipe& stderr, const ChildProcess::Pipe& stdin, const ChildProcess::Pipe& stdout) : pipes{stderr, stdin, stdout}, serr(pipes.stderr.read_fd(), io::never_close_handle), sin(pipes.stdin.write_fd(), io::never_close_handle), sout(pipes.stdout.read_fd(), io::never_close_handle), cerr(&serr), cin(&sin), cout(&sout), original_parent_pid(::getpid()), original_child_pid(pid) { } ~Private() { // Check if we are in the original parent process. if (original_parent_pid == getpid()) { // If so, check if we are considering a valid pid here. // If so, we kill the original child. if (original_child_pid != -1) ::kill(original_child_pid, SIGKILL); } } struct { ChildProcess::Pipe stdin; ChildProcess::Pipe stdout; ChildProcess::Pipe stderr; } pipes; io::stream_buffer serr; io::stream_buffer sin; io::stream_buffer sout; std::istream cerr; std::ostream cin; std::istream cout; // We need to store the original parent pid as we might have been forked // and with our automatic cleanup in place, it might happen that the d'tor // is called from the child process. pid_t original_parent_pid; pid_t original_child_pid; }; ChildProcess ChildProcess::invalid() { // We take the init process as child. static const pid_t invalid_pid = 1; return ChildProcess(invalid_pid, Pipe::invalid(), Pipe::invalid(), Pipe::invalid()); } ChildProcess::ChildProcess(pid_t pid, const ChildProcess::Pipe& stdin_pipe, const ChildProcess::Pipe& stdout_pipe, const ChildProcess::Pipe& stderr_pipe) : Process(pid), d(new Private{pid, stdin_pipe, stdout_pipe, stderr_pipe}) { } ChildProcess::~ChildProcess() { } wait::Result ChildProcess::wait_for(const wait::Flags& flags) { int status = -1; pid_t result_pid = ::waitpid(pid(), std::addressof(status), static_cast(flags)); if (result_pid == -1) throw std::system_error(errno, std::system_category()); wait::Result result; if (result_pid == 0) { result.status = wait::Result::Status::no_state_change; return result; } if (WIFEXITED(status)) { result.status = wait::Result::Status::exited; result.detail.if_exited.status = static_cast(WEXITSTATUS(status)); } else if (WIFSIGNALED(status)) { result.status = wait::Result::Status::signaled; result.detail.if_signaled.signal = static_cast(WTERMSIG(status)); result.detail.if_signaled.core_dumped = WCOREDUMP(status); } else if (WIFSTOPPED(status)) { result.status = wait::Result::Status::stopped; result.detail.if_stopped.signal = static_cast(WSTOPSIG(status)); } else if (WIFCONTINUED(status)) { result.status = wait::Result::Status::continued; } return result; } std::istream& ChildProcess::cerr() { return d->cerr; } std::ostream& ChildProcess::cin() { return d->cin; } std::istream& ChildProcess::cout() { return d->cout; } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/backtrace.cpp0000644000015201777760000000722012315241606023653 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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ß */ #include "backtrace.h" #include #include namespace bt = core::posix::backtrace; namespace impl { std::tuple demangle(const std::string& symbol) { int status = 1; auto result = abi::__cxa_demangle(symbol.c_str(), nullptr, nullptr, &status); if (!result || status != 0) { return std::make_tuple(std::string(), false); } std::string s{result}; ::free(result); return std::make_tuple(s, true); } struct Frame : public bt::Frame { struct Symbol : public bt::Frame::Symbol { Symbol(const char* symbol) : raw_(symbol) { auto first = raw_.find_first_of("("); auto last = raw_.find_last_of(")"); if (first != std::string::npos && last != std::string::npos) { auto mangled_symbol = raw_.substr(first+1, (last-1) - (first+1)); auto plus = mangled_symbol.find_first_of("+"); if (plus != std::string::npos) mangled_symbol.erase(plus); std::tie(demangled_, is_cxx_) = demangle(mangled_symbol); if (!is_cxx_) demangled_ = raw_; } } bool is_cxx() const { return is_cxx_; } std::string demangled() const { return demangled_; } std::string raw() const { return raw_; } std::string raw_; std::string demangled_; bool is_cxx_ = false; }; std::size_t depth_; void* frame_pointer_; Symbol symbol_; Frame(std::size_t depth, void* frame_pointer, const char* symbol) : depth_(depth), frame_pointer_(frame_pointer), symbol_(symbol) { } std::size_t depth() const { return depth_; } virtual void* frame_pointer() const { return frame_pointer_; } const Symbol& symbol() const { return symbol_; } }; } std::shared_ptr bt::Frame::Symbol::for_testing_from_raw_symbol(const char* symbol) { return std::shared_ptr(new impl::Frame::Symbol(symbol)); } void bt::visit_with_handler(const bt::FrameHandler& handler) { static const unsigned int max_frames=64; void *frames[max_frames]; auto frame_count = ::backtrace(frames, max_frames); auto symbols = ::backtrace_symbols(frames, frame_count); struct Scope { Scope(char** symbols) : symbols(symbols) { } ~Scope() { ::free(symbols); } char** symbols = nullptr; } scope{symbols}; for (int i = 0; i < frame_count; i++) { impl::Frame frame(i, frames[i], symbols[i]); if (!handler(frame)) return; } } process-cpp-1.0.0+14.04.20140328/src/core/posix/process_group.cpp0000644000015201777760000000204112315241606024622 0ustar pbusernogroup00000000000000/* * 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ß */ #include namespace core { namespace posix { struct ProcessGroup::Private { pid_t id; }; pid_t ProcessGroup::id() const { return d->id; } ProcessGroup::ProcessGroup(pid_t id) : Signalable(-id), // We rely on ::kill to deliver signals, thus negate the id (see man 2 kill). d(new Private{id}) { } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/process.cpp0000644000015201777760000000335712315241606023421 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include #include namespace core { namespace posix { struct Process::Private { pid_t pid; }; Process Process::invalid() { static const pid_t invalid_pid = 0; Process p(invalid_pid); p.d->pid = -1; return p; } Process::Process(pid_t pid) : Signalable(pid), d(new Private{pid}) { if (pid < 0) throw std::runtime_error("Cannot construct instance for invalid pid."); } Process::~Process() noexcept { } pid_t Process::pid() const { return d->pid; } ProcessGroup Process::process_group_or_throw() const { pid_t pgid = ::getpgid(pid()); if (pgid == -1) throw std::system_error(errno, std::system_category()); return ProcessGroup(pgid); } ProcessGroup Process::process_group(std::error_code& se) const noexcept(true) { pid_t pgid = ::getpgid(pid()); if (pgid == -1) { se = std::error_code(errno, std::system_category()); } return ProcessGroup(pgid); } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/signalable.cpp0000644000015201777760000000246212315241606024040 0ustar pbusernogroup00000000000000/* * 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ß */ #include namespace core { namespace posix { struct Signalable::Private { pid_t pid; }; Signalable::Signalable(pid_t pid) : d(new Private{pid}) { } void Signalable::send_signal_or_throw(Signal signal) { auto result = ::kill(d->pid, static_cast(signal)); if (result == -1) throw std::system_error(errno, std::system_category()); } void Signalable::send_signal(Signal signal, std::error_code& e) noexcept { auto result = ::kill(d->pid, static_cast(signal)); if (result == -1) { e = std::error_code(errno, std::system_category()); } } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/CMakeLists.txt0000644000015201777760000000134212315241606023767 0ustar pbusernogroup00000000000000# 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 add_library( posix-process process.cpp ) add_subdirectory(linux) process-cpp-1.0.0+14.04.20140328/src/core/posix/wait.cpp0000644000015201777760000000163712315241606022706 0ustar pbusernogroup00000000000000/* * 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ß */ #include namespace core { namespace posix { namespace wait { Flags operator|(Flags l, Flags r) { return static_cast(static_cast(l) | static_cast(r)); } } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/exec.cpp0000644000015201777760000000333512315241606022663 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include #include #include namespace core { namespace posix { ChildProcess exec(const std::string& fn, const std::vector& argv, const std::map& env, const StandardStream& flags) { return posix::fork([fn, argv, env]() { char** it; char** pargv; char** penv; it = pargv = new char*[argv.size()+2]; *it = ::strdup(fn.c_str()); it++; for (auto element : argv) { *it = ::strdup(element.c_str()); it++; } *it = nullptr; it = penv = new char*[env.size()+1]; for (auto pair : env) { *it = ::strdup((pair.first + "=" + pair.second).c_str()); it++; } *it = nullptr; return static_cast(execve(fn.c_str(), pargv, penv)); }, flags); } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/standard_stream.cpp0000644000015201777760000000214212315241606025105 0ustar pbusernogroup00000000000000/* * 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ß */ #include namespace core { namespace posix { StandardStream operator|(StandardStream l, StandardStream r) { return static_cast(static_cast(l) | static_cast(r)); } StandardStream operator&(StandardStream l, StandardStream r) { return static_cast(static_cast(l) & static_cast(r)); } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/linux/0000755000015201777760000000000012315242015022361 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/src/core/posix/linux/CMakeLists.txt0000644000015201777760000000140412315241606025125 0ustar pbusernogroup00000000000000# 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 add_library( linux-process process.cpp ) target_link_libraries( linux-process posix-process ) process-cpp-1.0.0+14.04.20140328/src/core/posix/linux/proc/0000755000015201777760000000000012315242015023324 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/src/core/posix/linux/proc/process/0000755000015201777760000000000012315242015025002 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/src/core/posix/linux/proc/process/state.cpp0000644000015201777760000000162112315241606026633 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include namespace core { namespace posix { namespace linux { namespace proc { namespace process { } } } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/linux/proc/process/oom_score.cpp0000644000015201777760000000222412315241606027500 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include namespace core { namespace posix { namespace linux { namespace proc { namespace process { const posix::Process& operator>>(const posix::Process& process, OomScore& score) { std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_score"; std::ifstream in(ss.str()); in >> score.value; return process; } } } } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/linux/proc/process/oom_adj.cpp0000644000015201777760000000327212315241606027127 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include #include #include namespace core { namespace posix { namespace linux { namespace proc { namespace process { int OomAdj::disable_value() { return OOM_DISABLE; } int OomAdj::min_value() { return OOM_ADJUST_MIN; } int OomAdj::max_value() { return OOM_ADJUST_MAX; } const posix::Process& operator>>(const posix::Process& process, OomAdj& adj) { std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_adj"; std::ifstream in(ss.str()); in >> adj.value; return process; } const posix::Process& operator<<(const posix::Process& process, const OomAdj& adj) { if (!adj.is_valid()) throw std::logic_error("Value for adjusting the oom score is invalid."); std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_adj"; std::ofstream out(ss.str()); out << adj.value; return process; } } } } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/linux/proc/process/stat.cpp0000644000015201777760000000530312315241606026467 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include #include namespace core { namespace posix { namespace linux { namespace proc { namespace process { std::istream& operator>>(std::istream& in, State& state) { char c; in >> c; state = static_cast(c); return in; } std::istream& operator>>(std::istream& in, Stat& stat) { in >> stat.pid >> stat.executable >> stat.state >> stat.parent >> stat.process_group >> stat.session_id >> stat.tty_nr >> stat.controlling_process_group >> stat.kernel_flags >> stat.minor_faults_count >> stat.minor_faults_count_by_children >> stat.major_faults_count >> stat.major_faults_count_by_children >> stat.time.user >> stat.time.system >> stat.time.user_for_children >> stat.time.system_for_children >> stat.priority >> stat.nice >> stat.thread_count >> stat.time_before_next_sig_alarm >> stat.start_time >> stat.size.virt >> stat.size.resident_set >> stat.size.resident_set_limit >> stat.addresses.start_code >> stat.addresses.end_code >> stat.addresses.start_stack >> stat.addresses.stack_pointer >> stat.addresses.instruction_pointer >> stat.signals.pending >> stat.signals.blocked >> stat.signals.ignored >> stat.signals.caught >> stat.channel >> stat.swap_count >> stat.swap_count_children >> stat.exit_signal >> stat.cpu_count >> stat.realtime_priority >> stat.scheduling_policy >> stat.aggregated_block_io_delays >> stat.guest_time >> stat.guest_time_children; return in; } const posix::Process& operator>>(const posix::Process& process, Stat& stat) { std::stringstream ss; ss << "/proc/" << process.pid() << "/stat"; std::ifstream in(ss.str()); in >> stat; return process; } } } } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/linux/proc/process/oom_score_adj.cpp0000644000015201777760000000331312315241606030316 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include #include #include namespace core { namespace posix { namespace linux { namespace proc { namespace process { int OomScoreAdj::min_value() { return OOM_SCORE_ADJ_MIN; } int OomScoreAdj::max_value() { return OOM_SCORE_ADJ_MAX; } const posix::Process& operator>>(const posix::Process& process, OomScoreAdj& score_adj) { std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_score_adj"; std::ifstream in(ss.str()); in >> score_adj.value; return process; } const posix::Process& operator<<(const posix::Process& process, const OomScoreAdj& score_adj) { if (!score_adj.is_valid()) throw std::logic_error("Value for adjusting the oom score is invalid."); std::stringstream ss; ss << "/proc/" << process.pid() << "/oom_score_adj"; std::ofstream out(ss.str()); out << score_adj.value; return process; } } } } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/signal.cpp0000644000015201777760000001361412315241606023215 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include #include #include #include namespace impl { void set_thread_signal_mask(::sigset_t* new_mask, ::sigset_t* old_mask) { ::pthread_sigmask(SIG_BLOCK, new_mask, old_mask); } void set_process_signal_mask(::sigset_t* new_mask, ::sigset_t* old_mask) { ::sigprocmask(SIG_BLOCK, new_mask, old_mask); } class SignalTrap : public core::posix::SignalTrap { public: enum class Scope { process, thread }; enum class State { not_running, running }; SignalTrap(Scope scope, std::initializer_list blocked_signals) : scope(scope), state(State::not_running), event_fd(::eventfd(0, EFD_CLOEXEC | EFD_NONBLOCK)) { if (event_fd == -1) throw std::system_error(errno, std::system_category()); ::sigemptyset(&blocked_signals_mask); for(auto signal : blocked_signals) ::sigaddset(&blocked_signals_mask, static_cast(signal)); switch (scope) { case Scope::process: set_process_signal_mask(&blocked_signals_mask, &old_signals_mask); break; case Scope::thread: set_thread_signal_mask(&blocked_signals_mask, &old_signals_mask); break; } } ~SignalTrap() { switch (scope) { case Scope::process: set_process_signal_mask(&old_signals_mask, nullptr); break; case Scope::thread: set_thread_signal_mask(&old_signals_mask, nullptr); break; } ::close(event_fd); } bool has(core::posix::Signal signal) override { return ::sigismember(&blocked_signals_mask, static_cast(signal)); } void run() override { static constexpr int signal_fd_idx = 0; static constexpr int event_fd_idx = 1; static constexpr int signal_info_buffer_size = 5; if (state.load() == State::running) throw std::runtime_error("SignalTrap::run can only be run once."); state.store(State::running); // Make sure we clean up the signal fd whenever // we leave the scope of run. struct Scope { ~Scope() { if (signal_fd != -1) ::close(signal_fd); } int signal_fd; } scope{::signalfd(-1, &blocked_signals_mask, SFD_CLOEXEC | SFD_NONBLOCK)}; if (scope.signal_fd == -1) throw std::system_error(errno, std::system_category()); pollfd fds[2]; signalfd_siginfo signal_info[signal_info_buffer_size]; for (;;) { fds[signal_fd_idx] = {scope.signal_fd, POLLIN, 0}; fds[event_fd_idx] = {event_fd, POLLIN, 0}; auto rc = ::poll(fds, 2, -1); if (rc == -1) { if (errno == EINTR) continue; break; } if (rc == 0) continue; if (fds[signal_fd_idx].revents & POLLIN) { auto result = ::read(scope.signal_fd, signal_info, sizeof(signal_info)); for (uint i = 0; i < result / sizeof(signalfd_siginfo); i++) { if (has(static_cast(signal_info[i].ssi_signo))) { on_signal_raised( static_cast( signal_info[i].ssi_signo)); } } } if (fds[event_fd_idx].revents & POLLIN) { std::int64_t value{1}; // Consciously void-ing the return value here. // Not much we can do about an error. auto result = ::read(event_fd, &value, sizeof(value)); (void) result; break; } } state.store(State::not_running); } void stop() override { static const std::int64_t value = {1}; if (sizeof(value) != ::write(event_fd, &value, sizeof(value))) throw std::system_error(errno, std::system_category()); } core::Signal& signal_raised() override { return on_signal_raised; } private: Scope scope; std::atomic state; int event_fd; core::Signal on_signal_raised; ::sigset_t old_signals_mask; ::sigset_t blocked_signals_mask; }; } std::shared_ptr core::posix::trap_signals_for_process( std::initializer_list blocked_signals) { return std::make_shared( impl::SignalTrap::Scope::process, blocked_signals); } std::shared_ptr core::posix::trap_signals_for_all_subsequent_threads( std::initializer_list blocked_signals) { return std::make_shared( impl::SignalTrap::Scope::thread, blocked_signals); } process-cpp-1.0.0+14.04.20140328/src/core/posix/this_process.cpp0000644000015201777760000000735512315241615024452 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include #include #include #include #include #include #include #if defined(_GNU_SOURCE) #include #else extern char** environ; #endif namespace core { namespace posix { namespace this_process { namespace env { namespace { std::mutex& env_guard() { static std::mutex m; return m; } } void for_each(const std::function& functor) noexcept(true) { std::lock_guard lg(env_guard()); auto it = ::environ; while (it != nullptr && *it != nullptr) { std::string line(*it); functor(line.substr(0,line.find_first_of('=')), line.substr(line.find_first_of('=')+1)); ++it; } } std::string get_or_throw(const std::string& key) { std::lock_guard lg(env_guard()); auto result = ::getenv(key.c_str()); if (result == nullptr) { std::stringstream ss; ss << "Variable with name " << key << " is not defined in the environment"; throw std::runtime_error(ss.str()); } return std::string{result}; } std::string get(const std::string& key, const std::string& default_value) noexcept(true) { std::lock_guard lg(env_guard()); auto result = ::getenv(key.c_str()); return std::string{result ? result : default_value}; } void unset_or_throw(const std::string& key) { std::lock_guard lg(env_guard()); auto rc = ::unsetenv(key.c_str()); if (rc == -1) throw std::system_error(errno, std::system_category()); } bool unset(const std::string& key, std::error_code& se) noexcept(true) { std::lock_guard lg(env_guard()); auto rc = ::unsetenv(key.c_str()); if (rc == -1) { se = std::error_code(errno, std::system_category()); return false; } return true; } void set_or_throw(const std::string& key, const std::string& value) { std::lock_guard lg(env_guard()); static const int overwrite = 0; auto rc = ::setenv(key.c_str(), value.c_str(), overwrite); if (rc == -1) throw std::system_error(errno, std::system_category()); } bool set(const std::string &key, const std::string &value, std::error_code& se) noexcept(true) { std::lock_guard lg(env_guard()); static const int overwrite = 0; auto rc = ::setenv(key.c_str(), value.c_str(), overwrite); if (rc == -1) { se = std::error_code(errno, std::system_category()); return false; } return true; } } Process instance() noexcept(true) { static const Process self{getpid()}; return self; } Process parent() noexcept(true) { return Process(getppid()); } std::istream& cin() noexcept(true) { return std::cin; } std::ostream& cout() noexcept(true) { return std::cout; } std::ostream& cerr() noexcept(true) { return std::cerr; } } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/fork.cpp0000644000015201777760000001434412315241606022702 0ustar pbusernogroup00000000000000/* * 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ß */ #include #include #include "backtrace.h" #include #include #include #include namespace { void redirect_stream_to_fd(int fd, int stream) { auto rc = ::dup2(fd, stream); if (rc == -1) throw std::system_error(errno, std::system_category()); } void print_backtrace(std::ostream& out, const std::string& line_prefix) { core::posix::backtrace::visit_with_handler([&out, line_prefix](const core::posix::backtrace::Frame& frame) { out << line_prefix << std::dec << std::setw(2) << frame.depth() << "@" << std::hex << std::setw(14) << frame.frame_pointer() << ": " << (frame.symbol().is_cxx() ? frame.symbol().demangled() : frame.symbol().raw()) << std::endl; return true; }); } } namespace core { namespace posix { bool is_child(pid_t pid) { return pid == 0; } ChildProcess fork(const std::function& main, const StandardStream& flags) { ChildProcess::Pipe stdin_pipe{ChildProcess::Pipe::invalid()}; ChildProcess::Pipe stdout_pipe{ChildProcess::Pipe::invalid()}; ChildProcess::Pipe stderr_pipe{ChildProcess::Pipe::invalid()}; if ((flags & StandardStream::stdin) != StandardStream::empty) stdin_pipe = ChildProcess::Pipe(); if ((flags & StandardStream::stdout) != StandardStream::empty) stdout_pipe = ChildProcess::Pipe(); if ((flags & StandardStream::stderr) != StandardStream::empty) stderr_pipe = ChildProcess::Pipe(); pid_t pid = ::fork(); if (pid == -1) throw std::system_error(errno, std::system_category()); if (is_child(pid)) { posix::exit::Status result = posix::exit::Status::failure; try { stdin_pipe.close_write_fd(); stdout_pipe.close_read_fd(); stderr_pipe.close_read_fd(); // We replace stdin and stdout of the child process first: if ((flags & StandardStream::stdin) != StandardStream::empty) redirect_stream_to_fd(stdin_pipe.read_fd(), STDIN_FILENO); if ((flags & StandardStream::stdout) != StandardStream::empty) redirect_stream_to_fd(stdout_pipe.write_fd(), STDOUT_FILENO); if ((flags & StandardStream::stderr) != StandardStream::empty) redirect_stream_to_fd(stderr_pipe.write_fd(), STDERR_FILENO); result = main(); } catch(const std::exception& e) { std::cerr << "core::posix::fork(): An unhandled std::exception occured in the child process:" << std::endl << " what(): " << e.what() << std::endl; print_backtrace(std::cerr, " "); } catch(...) { std::cerr << "core::posix::fork(): An unhandled exception occured in the child process." << std::endl; print_backtrace(std::cerr, " "); } // We have to ensure that we exit here. Otherwise, we run into // all sorts of weird issues. ::exit(static_cast(result)); } // We are in the parent process, and create a process object // corresponding to the newly forked process. stdin_pipe.close_read_fd(); stdout_pipe.close_write_fd(); stderr_pipe.close_write_fd(); return ChildProcess(pid, stdin_pipe, stdout_pipe, stderr_pipe); } ChildProcess vfork(const std::function& main, const StandardStream& flags) { ChildProcess::Pipe stdin_pipe, stdout_pipe, stderr_pipe; pid_t pid = ::vfork(); if (pid == -1) throw std::system_error(errno, std::system_category()); if (is_child(pid)) { posix::exit::Status result = posix::exit::Status::failure; try { // We replace stdin and stdout of the child process first: stdin_pipe.close_write_fd(); stdout_pipe.close_read_fd(); stderr_pipe.close_read_fd(); // We replace stdin and stdout of the child process first: if ((flags & StandardStream::stdin) != StandardStream::empty) redirect_stream_to_fd(stdin_pipe.read_fd(), STDIN_FILENO); if ((flags & StandardStream::stdout) != StandardStream::empty) redirect_stream_to_fd(stdout_pipe.write_fd(), STDOUT_FILENO); if ((flags & StandardStream::stderr) != StandardStream::empty) redirect_stream_to_fd(stderr_pipe.write_fd(), STDERR_FILENO); result = main(); } catch(const std::exception& e) { std::cerr << "core::posix::fork(): An unhandled std::exception occured in the child process:" << std::endl << " what(): " << e.what() << std::endl; print_backtrace(std::cerr, " "); } catch(...) { std::cerr << "core::posix::fork(): An unhandled exception occured in the child process." << std::endl; print_backtrace(std::cerr, " "); } // We have to ensure that we exit here. Otherwise, we run into // all sorts of weird issues. ::exit(static_cast(result)); } // We are in the parent process, and create a process object // corresponding to the newly forked process. // Close the parent's pipe end stdin_pipe.close_read_fd(); stdout_pipe.close_write_fd(); stderr_pipe.close_write_fd(); return ChildProcess(pid, stdin_pipe, stdout_pipe, stderr_pipe); } } } process-cpp-1.0.0+14.04.20140328/src/core/posix/backtrace.h0000644000015201777760000000615212315241606023323 0ustar pbusernogroup00000000000000/* * Copyright © 2014 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_BACKTRACE_H_ #define CORE_POSIX_BACKTRACE_H_ #include #include #include #include namespace core { namespace posix { namespace backtrace { /** * @brief The Frame class models an individual frame of a backtrace. */ class Frame { public: /** * @brief The Symbol class models the symbolic representation of a frame pointer. */ class Symbol { public: static std::shared_ptr for_testing_from_raw_symbol(const char* symbol); Symbol(const Symbol&) = delete; virtual ~Symbol() = default; Symbol& operator=(const Symbol&) = delete; /** * @brief is_cxx checks whether the symbol refers to a mangled C++ symbol. * @return true iff the symbol refers to a mangled C++ symbol. */ virtual bool is_cxx() const = 0; /** * @brief demangled returns the demangled C++ symbol name or raw. */ virtual std::string demangled() const = 0; /** * @brief raw The raw symbolic representation of a frame pointer. * @return */ virtual std::string raw() const = 0; protected: Symbol() = default; }; Frame(const Frame&) = delete; virtual ~Frame() = default; Frame& operator=(const Frame&) = delete; /** * @brief depth returns the depth of this frame in the overall backtrace. */ virtual std::size_t depth() const = 0; /** * @brief frame_pointer returns the the raw frame pointer of this frame. * @return */ virtual void* frame_pointer() const = 0; /** * @brief symbol returns the symbolic representation of this frame. */ virtual const Symbol& symbol() const = 0; protected: Frame() = default; }; /** * @brief FrameHandler is the functor invoked for every frame of a backtrace. * * A FrameHandler should return true if it wants to continue walking the stack * or false otherwise. */ typedef std::function FrameHandler; /** *@brief visit_with_handler iterates the backtrace of the calling program, *invoking the handler for every frame. * * A FrameHandler should return true if it wants to continue walking the stack * or false otherwise * * @param handler The handler invoked for every frame. */ void visit_with_handler(const FrameHandler& handler); } } } #endif // CORE_POSIX_BACKTRACE_H_ process-cpp-1.0.0+14.04.20140328/src/CMakeLists.txt0000644000015201777760000000356312315241606021704 0ustar pbusernogroup00000000000000# 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 add_library( process-cpp SHARED core/posix/backtrace.h core/posix/backtrace.cpp core/posix/child_process.cpp core/posix/exec.cpp core/posix/fork.cpp core/posix/process.cpp core/posix/process_group.cpp core/posix/signal.cpp core/posix/signalable.cpp core/posix/standard_stream.cpp core/posix/wait.cpp core/posix/this_process.cpp core/posix/linux/proc/process/oom_adj.cpp core/posix/linux/proc/process/oom_score.cpp core/posix/linux/proc/process/oom_score_adj.cpp core/posix/linux/proc/process/stat.cpp core/testing/cross_process_sync.cpp core/testing/fork_and_run.cpp ) target_link_libraries( process-cpp ${Boost_LIBRARIES} ${CMAKE_THREAD_LIBS_INIT} ) # We compile with all symbols visible by default. For the shipping library, we strip # out all symbols that are not in core::* set(symbol_map "${CMAKE_SOURCE_DIR}/symbols.map") set_target_properties( process-cpp PROPERTIES LINK_FLAGS "${ldflags} -Wl,--version-script,${symbol_map}" LINK_DEPENDS ${symbol_map} VERSION ${PROCESS_CPP_VERSION_MAJOR}.${PROCESS_CPP_VERSION_MINOR}.${PROCESS_CPP_VERSION_PATCH} SOVERSION ${PROCESS_CPP_VERSION_MAJOR} ) install( TARGETS process-cpp LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR} ) process-cpp-1.0.0+14.04.20140328/data/0000755000015201777760000000000012315242015017252 5ustar pbusernogroup00000000000000process-cpp-1.0.0+14.04.20140328/data/CMakeLists.txt0000644000015201777760000000150312315241606022016 0ustar pbusernogroup00000000000000# 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 configure_file( process-cpp.pc.in process-cpp.pc @ONLY ) install( FILES ${CMAKE_CURRENT_BINARY_DIR}/process-cpp.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig ) process-cpp-1.0.0+14.04.20140328/data/process-cpp.pc.in0000644000015201777760000000055412315241606022452 0ustar pbusernogroup00000000000000prefix=@CMAKE_INSTALL_PREFIX@ exec_prefix=${prefix} libdir=${exec_prefix}/lib includedir=${exec_prefix}/include Name: @CMAKE_PROJECT_NAME@ Description: A simple and lightweight C++11 wrapper around process control Version: @PROCESS_CPP_VERSION_MAJOR@.@PROCESS_CPP_VERSION_MINOR@.@PROCESS_CPP_VERSION_PATCH@ Libs: -L${libdir} -lprocess-cpp Cflags: -I${includedir}process-cpp-1.0.0+14.04.20140328/COPYING0000644000015201777760000001674312315241606017414 0ustar pbusernogroup00000000000000 GNU LESSER GENERAL PUBLIC LICENSE Version 3, 29 June 2007 Copyright (C) 2007 Free Software Foundation, Inc. Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. This version of the GNU Lesser General Public License incorporates the terms and conditions of version 3 of the GNU General Public License, supplemented by the additional permissions listed below. 0. Additional Definitions. As used herein, "this License" refers to version 3 of the GNU Lesser General Public License, and the "GNU GPL" refers to version 3 of the GNU General Public License. "The Library" refers to a covered work governed by this License, other than an Application or a Combined Work as defined below. An "Application" is any work that makes use of an interface provided by the Library, but which is not otherwise based on the Library. Defining a subclass of a class defined by the Library is deemed a mode of using an interface provided by the Library. A "Combined Work" is a work produced by combining or linking an Application with the Library. The particular version of the Library with which the Combined Work was made is also called the "Linked Version". The "Minimal Corresponding Source" for a Combined Work means the Corresponding Source for the Combined Work, excluding any source code for portions of the Combined Work that, considered in isolation, are based on the Application, and not on the Linked Version. The "Corresponding Application Code" for a Combined Work means the object code and/or source code for the Application, including any data and utility programs needed for reproducing the Combined Work from the Application, but excluding the System Libraries of the Combined Work. 1. Exception to Section 3 of the GNU GPL. You may convey a covered work under sections 3 and 4 of this License without being bound by section 3 of the GNU GPL. 2. Conveying Modified Versions. If you modify a copy of the Library, and, in your modifications, a facility refers to a function or data to be supplied by an Application that uses the facility (other than as an argument passed when the facility is invoked), then you may convey a copy of the modified version: a) under this License, provided that you make a good faith effort to ensure that, in the event an Application does not supply the function or data, the facility still operates, and performs whatever part of its purpose remains meaningful, or b) under the GNU GPL, with none of the additional permissions of this License applicable to that copy. 3. Object Code Incorporating Material from Library Header Files. The object code form of an Application may incorporate material from a header file that is part of the Library. You may convey such object code under terms of your choice, provided that, if the incorporated material is not limited to numerical parameters, data structure layouts and accessors, or small macros, inline functions and templates (ten or fewer lines in length), you do both of the following: a) Give prominent notice with each copy of the object code that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the object code with a copy of the GNU GPL and this license document. 4. Combined Works. You may convey a Combined Work under terms of your choice that, taken together, effectively do not restrict modification of the portions of the Library contained in the Combined Work and reverse engineering for debugging such modifications, if you also do each of the following: a) Give prominent notice with each copy of the Combined Work that the Library is used in it and that the Library and its use are covered by this License. b) Accompany the Combined Work with a copy of the GNU GPL and this license document. c) For a Combined Work that displays copyright notices during execution, include the copyright notice for the Library among these notices, as well as a reference directing the user to the copies of the GNU GPL and this license document. d) Do one of the following: 0) Convey the Minimal Corresponding Source under the terms of this License, and the Corresponding Application Code in a form suitable for, and under terms that permit, the user to recombine or relink the Application with a modified version of the Linked Version to produce a modified Combined Work, in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source. 1) Use a suitable shared library mechanism for linking with the Library. A suitable mechanism is one that (a) uses at run time a copy of the Library already present on the user's computer system, and (b) will operate properly with a modified version of the Library that is interface-compatible with the Linked Version. e) Provide Installation Information, but only if you would otherwise be required to provide such information under section 6 of the GNU GPL, and only to the extent that such information is necessary to install and execute a modified version of the Combined Work produced by recombining or relinking the Application with a modified version of the Linked Version. (If you use option 4d0, the Installation Information must accompany the Minimal Corresponding Source and Corresponding Application Code. If you use option 4d1, you must provide the Installation Information in the manner specified by section 6 of the GNU GPL for conveying Corresponding Source.) 5. Combined Libraries. You may place library facilities that are a work based on the Library side by side in a single library together with other library facilities that are not Applications and are not covered by this License, and convey such a combined library under terms of your choice, if you do both of the following: a) Accompany the combined library with a copy of the same work based on the Library, uncombined with any other library facilities, conveyed under the terms of this License. b) Give prominent notice with the combined library that part of it is a work based on the Library, and explaining where to find the accompanying uncombined form of the same work. 6. Revised Versions of the GNU Lesser General Public License. The Free Software Foundation may publish revised and/or new versions of the GNU Lesser General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Library as you received it specifies that a certain numbered version of the GNU Lesser General Public License "or any later version" applies to it, you have the option of following the terms and conditions either of that published version or of any later version published by the Free Software Foundation. If the Library as you received it does not specify a version number of the GNU Lesser General Public License, you may choose any version of the GNU Lesser General Public License ever published by the Free Software Foundation. If the Library as you received it specifies that a proxy can decide whether future versions of the GNU Lesser General Public License shall apply, that proxy's public statement of acceptance of any version is permanent authorization for you to choose that version for the Library.