VLink 2.0.0
A high-performance communication middleware
载入中...
搜索中...
未找到
process.h 文件参考

Cross-platform child process management with I/O piping and async callbacks. 更多...

#include <cstdint>
#include <functional>
#include <memory>
#include <string>
#include <unordered_map>
#include <vector>
#include "./macros.h"
process.h 的引用(Include)关系图:

浏览该文件的源代码.

 Cross-platform child process with async I/O and state notification. 更多...

命名空间

详细描述

Cross-platform child process management with I/O piping and async callbacks.

Process provides a Qt-QProcess-inspired API for launching, monitoring and communicating with child processes. It supports:

  • Asynchronous state change, I/O ready-read and exit callbacks.
  • Multiple channel modes (separate stdout/stderr, merged, or forwarded to parent).
  • Line-by-line and bulk I/O reading from stdout and stderr.
  • Writing to stdin with a configurable timeout.
  • Synchronous helpers (execute, start_detached) for fire-and-forget use cases.

Channel modes:

Mode stdout stderr
kSeparateMode Buffered pipe Buffered pipe
kMergedMode Buffered pipe Merged into stdout
kForwardedMode Forwarded to parent Forwarded to parent
kForwardedOutputMode Forwarded to parent Buffered pipe
kForwardedErrorMode Buffered pipe Forwarded to parent
注解
  • All callbacks are invoked from an internal monitor thread; access shared state with care.
  • close() requests termination and optionally force-kills after a timeout.
  • Process objects are non-moveable and non-copyable.
  • The destructor waits kDestructorWaitTimeoutMs (5 s) for the process to exit.
Example
std::string line;
while (proc.can_read_line_stdout()) {
proc.read_line_stdout(line);
// handle line
}
});
// handle exit
});
proc.start("/usr/bin/ls", {"-la"});