Мне нужно запустить команду Linux CLI и получить вывод stdout из C.
Я могу использовать pipe () для создания канала, затем fork / exec, перенаправив дескриптор stdout дочернего элемента в канал перед вызовом exec () и чтение из канала в родительском. Плюс мне нужно подождать ребенка.
Есть ли простой вызов для выполнения fork + redirect + exec + wait, например, system () выполняет fork + exec + wait, только system () не выполняет перенаправление.
Есть popen (), которая выполняет fork + redirect + exec, но не ждет, поэтому я не могу получить статус выхода.