boost::process::v1::system
// In header: <boost/process/v1/system.hpp> template<typename ... Args> int system(Args &&... args);
啟動一個行程並等待其結束。它的功能類似於 std::system,但允許使用 boost.process 提供的所有屬性。它將執行行程並等待其結束;然後返回 exit_code(結束代碼)。
int ret = system("ls");
![]() |
重要 |
---|---|
將此函式與同步管道一起使用會導致許多潛在的死結。 |
當此函式與非同步屬性一起使用且未傳遞 io_context 物件時,system 函式將建立一個 io_context 物件並執行它。當 io_context 物件被傳遞給函式時,system 函式將檢查它是否處於活動狀態,如果不是,則呼叫 io_context::run 函式。