![]() |
boost::process::posix_launcher — POSIX implementation of the Launcher concept.
class posix_launcher : public boost::process::launcher { public: // public member functions posix_launcher & set_input_behavior(int, stream_behavior) ; posix_launcher & set_output_behavior(int, stream_behavior) ; posix_launcher & merge_outputs(int, int) ; uid_t get_uid(void) const; posix_launcher & set_uid(uid_t) ; uid_t get_euid(void) const; posix_launcher & set_euid(uid_t) ; gid_t get_gid(void) const; posix_launcher & set_gid(gid_t) ; gid_t get_egid(void) const; posix_launcher & set_egid(gid_t) ; const std::string & get_chroot(void) const; posix_launcher & set_chroot(const std::string &) ; template<typename Command_Line> posix_child start(const Command_Line &) ; };
The posix_launcher class implements the Launcher concept with features only available in POSIX systems. Among these are the ability to set up more than three communication pipes and the possibility to change the security credentials of the spawned process as well as its file system root directory.
This class is built on top of the generic launcher so as to allow its trivial adoption. A program using the generic launcher may grow the need to use some POSIX-specific features. In that case, adapting the code is only a matter of redefining the appropriate object and later using the required extra features: there should be no need to modify the existing code in any other way.
posix_launcher
public member functionsposix_launcher & set_input_behavior(int desc, stream_behavior b) ;
Configures the input descriptor desc to behave as described by . If desc matches STDIN_FILENO (defined in cstdlib), this mimics the set_stdin_behavior() call.
Returns: | A reference to the launcher to allow daisy-chaining calls to redirection functions for simplicity. |
posix_launcher & set_output_behavior(int desc, stream_behavior b) ;
Configures the output descriptor desc to behave as described by . If desc matches STDOUT_FILENO or STDERR_FILENO (both defined in cstdlib), this mimics the set_stdout_behavior() and set_stderr_behavior() calls respectively.
Returns: | A reference to the launcher to allow daisy-chaining calls to redirection functions for simplicity. |
posix_launcher & merge_outputs(int from, int to) ;
Configures the launcher to merge to output streams; that is, that when the child process writes to from, the data seems to have been written to to. If from matches STDOUT_FILENO and to matches STDERR_FILENO (both defined in cstdlib), this mimics the REDIR_STDERR_TO_STDOUT flag passed to the constructor.
Returns: | A reference to the launcher to allow daisy-chaining calls to redirection functions for simplicity. |
uid_t get_uid(void ) const;
Returns the user identifier that will be used to launch the new child process. By default, this matches the user of the parent process at the moment of the creation of the launcher object.
posix_launcher & set_uid(uid_t uid) ;
Sets the UID credentials used to launch the new process to those given in uid.
Returns: | A reference to the launcher to allow daisy-chaining calls to configuration function for simplicity. |
uid_t get_euid(void ) const;
Returns the effective user identifier that will be used to launch the new child process. By default, this matches the effective user of the parent process at the moment of the creation of the launcher object.
posix_launcher & set_euid(uid_t euid) ;
Sets the effective UID credentials used to launch the new process to those given in euid.
Returns: | A reference to the launcher to allow daisy-chaining calls to configuration function for simplicity. |
gid_t get_gid(void ) const;
Returns the group identifier that will be used to launch the new child process. By default, this matches the group of the parent process at the moment of the creation of the launcher object.
posix_launcher & set_gid(gid_t gid) ;
Sets the GID credentials used to launch the new process to those given in gid.
Returns: | A reference to the launcher to allow daisy-chaining calls to configuration function for simplicity. |
gid_t get_egid(void ) const;
Returns the effective group identifier that will be used to launch the new child process. By default, this matches the effective group of the parent process at the moment of the creation of the launcher object.
posix_launcher & set_egid(gid_t egid) ;
Sets the effective GID credentials used to launch the new process to those given in egid.
Returns: | A reference to the launcher to allow daisy-chaining calls to configuration function for simplicity. |
const std::string & get_chroot(void ) const;
Gets a path to the directory that will be used to chroot the process to during execution. If the resulting string is empty, it means that no chroot shall take place (the default).
posix_launcher & set_chroot(const std::string & dir) ;
Sets the directory that will be used to chroot the process to during execution. dir may be empty to indicate that the process should not be chrooted (the default).
Returns: | A reference to the launcher to allow daisy-chaining calls to configuration function for simplicity. |
template<typename Command_Line> posix_child start(const Command_Line & cl) ;
Given a command line cl, starts a new process with all the parameters configured in the launcher. The launcher can be reused afterwards to launch other different command lines.
Returns: | A handle to the new child process. |
Copyright © 2006 Julio M. Merino Vidal |