Search code examples
c++popen

Alternative for popen pipe to execute program and read the output


Please, suggest good alternative for popen() to execute shell commands and then read the output.

EDIT: The alternative must be without fork() call. Because my server is already takes too much memory. Then ffmpeg need also memory and process size is increased! and I get the problems to fork() to memory weight server each time.


Solution

  • If you worry about copying the memory of the parent process when forking, then you need to use vfork() - a special version of "fork" that does not copy the memory of a parent process but requires the forked process to immediately issue execve().