Boost C++ 程式庫

...世界上最受推崇且設計精良的 C++ 程式庫專案之一。 Herb SutterAndrei Alexandrescu,《C++ 程式碼規範

PrevUpHomeNext

函式模板系統

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");
[Important] 重要

將此函式與同步管道一起使用會導致許多潛在的死結。

當此函式與非同步屬性一起使用且未傳遞 io_context 物件時,system 函式將建立一個 io_context 物件並執行它。當 io_context 物件被傳遞給函式時,system 函式將檢查它是否處於活動狀態,如果不是,則呼叫 io_context::run 函式。


PrevUpHomeNext