RStudio Launcher Plugin SDK
1.1.3
A software development kit for creating plugins that work the the RStudio Launcher.
|
25 #ifndef LAUNCHER_PLUGINS_PROCESS_HPP
26 #define LAUNCHER_PLUGINS_PROCESS_HPP
28 #include <Noncopyable.hpp>
34 #include <api/Job.hpp>
35 #include <system/FilePath.hpp>
36 #include <system/DateTime.hpp>
37 #include <system/User.hpp>
40 namespace launcher_plugins {
48 namespace launcher_plugins {
52 typedef std::function<void(
const Error&)> OnErrorCallback;
53 typedef std::function<void(
int)> OnExitCallback;
54 typedef std::function<void(
const std::string&)> OnOutputCallback;
299 PRIVATE_IMPL(m_baseImpl);
361 std::shared_ptr<AbstractChildProcess>* out_childProcess =
nullptr);
392 PRIVATE_IMPL_SHARED(m_impl);
404 Error getChildProcesses(pid_t in_parentPid, std::vector<ProcessInfo>& out_processes);
416 Error signalProcess(pid_t in_pid,
int in_signal,
bool in_processGroupOnly =
true);
425 std::string shellEscape(
const std::string& in_toEscape);
434 std::string shellEscape(
const FilePath& in_filePath);
FilePath StandardErrorFile
The file to which to write standard error. If not set, standard error will not be redirected.
Definition: Process.hpp:227
static TimeDuration Infinity()
Constructs a TimeDuration which represents "any amount of time". Use with caution.
OnExitCallback OnExit
Callback invoked when the asynchronous child process exits.
Definition: Process.hpp:131
std::string Executable
The executable or shell command to run. This value should either be an absolute path,...
Definition: Process.hpp:178
Class which represents a path on the system. May be any type of file (e.g. directory,...
Definition: FilePath.hpp:77
bool UseSandbox
Whether to use the rsandbox executable to launch the child in sandbox environment or launch the child...
Definition: Process.hpp:240
static Error runAsyncProcess(const ProcessOptions &in_options, const AsyncProcessCallbacks &in_callbacks, std::shared_ptr< AbstractChildProcess > *out_childProcess=nullptr)
Runs a child process asynchronously.
virtual Error writeToStdin(const std::string &in_string, bool in_eof)=0
Writes the specified string to stdin.
User RunAsUser
The user who the job should be run as.
Definition: Process.hpp:212
FilePath StandardOutputFile
The file to which to write standard output. If not set, standard output will not be redirected.
Definition: Process.hpp:222
Class which represents a system user.
Definition: User.hpp:55
std::string StdOut
Definition: Process.hpp:115
pid_t PGrp
Definition: Process.hpp:86
Callbacks that will be invoked when certain events happen in the asynchronous child process.
Definition: Process.hpp:121
static bool hasRunningChildren()
Checks whether the supervisor is tracking any processes which have not exited yet.
bool IsShellCommand
True if the executable is a shell command; False otherwise. Default: false.
Definition: Process.hpp:183
std::vector< std::string > Arguments
Definition: Process.hpp:77
std::string StdError
Definition: Process.hpp:112
std::string PamProfile
The PAM profile to load, if any.
Definition: Process.hpp:198
User Owner
Definition: Process.hpp:83
Represents the details of a process that is running on this machine.
Definition: Process.hpp:59
std::string Executable
Definition: Process.hpp:80
Defines a process that can be run.
Definition: Process.hpp:143
pid_t Pid
Definition: Process.hpp:89
Creates and manages non-blocking child processes.
Definition: Process.hpp:338
static Error getProcessInfo(pid_t in_pid, ProcessInfo &out_info)
Gets the process information for the process with the specified PID.
api::EnvironmentList Environment
The environment variables which should available to the process. If PATH is not set,...
Definition: Process.hpp:172
static void terminateAll()
Terminates all running children forcefully.
std::vector< std::string > Arguments
The arguments of the process. Each argument will be escaped using single quotations so that the value...
Definition: Process.hpp:152
Base class for a child process, which will be launched via rsandbox.
Definition: Process.hpp:251
pid_t PPid
Definition: Process.hpp:92
AbstractChildProcess(const ProcessOptions &in_options)
Constructor.
A blocking child process.
Definition: Process.hpp:305
Class which represents an error.
Definition: Error.hpp:174
ProcessResult()
Constructor.
Definition: Process.hpp:106
Error run()
Forks and executes the child process, passing along arguments and environment variables.
Represents an duration of time (e.g. 5 hours, 43 minutes, and 21 seconds) as opposed to a point in ti...
Definition: DateTime.hpp:48
std::string State
Definition: Process.hpp:95
ProcessInfo()
Constructor.
int ExitCode
Definition: Process.hpp:106
ProcessOptions()
Constructor.
Definition: Process.hpp:148
Class which can be inherited from to disallow copying of its child classes.
Definition: Noncopyable.hpp:34
SyncChildProcess(const ProcessOptions &in_options)
Constructor.
OnErrorCallback OnError
Callback invoked if the asynchronous child process encounters an error.
Definition: Process.hpp:126
std::string Password
The password of the user running the job, if any.
Definition: Process.hpp:205
pid_t getPid() const
Gets the PID of this child process.
OnOutputCallback OnStandardOutput
Callback invoked when the asynchronous child process writes to standard out.
Definition: Process.hpp:137
api::MountList Mounts
The set of mounts to be applied for the child process. Only mounts with a HostMountSource type will b...
Definition: Process.hpp:191
virtual ~AbstractChildProcess()=default
Virtual destructor for inheritance.
Error writeToStdin(const std::string &in_string, bool in_eof) override
Writes the specified string to stdin.
static bool waitForExit(const TimeDuration &in_maxWaitTime=TimeDuration::Infinity())
Waits for all child processes to exit.
OnOutputCallback OnStandardError
Callback invoked when the asynchronous child process writes to standard error.
Definition: Process.hpp:134
Represents the result of a synchronous child process.
Definition: Process.hpp:101
virtual Error terminate()
Terminates the child process.
FilePath WorkingDirectory
The directory from which to run the process. Must exist and be accessible by the RunAsUser.
Definition: Process.hpp:245
std::string StandardInput
The standard input that should be sent to the process.
Definition: Process.hpp:217
bool CloseStdIn
Whether to close write end of the standard input stream after the specified StandardInput is written....
Definition: Process.hpp:166