Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

popen equivalent in c++

Tags:

c++

posix

popen

Is their any C popen() equivalent in C++ ?

like image 993
Arif Avatar asked Jul 06 '10 21:07

Arif


People also ask

What is Popen in C?

The popen() function executes the command specified by the string command. It creates a pipe between the calling program and the executed command, and returns a pointer to a stream that can be used to either read from or write to the pipe.

What does the popen () return on success?

On success, open(), openat(), and creat() return the new file descriptor (a nonnegative integer). On error, -1 is returned and errno is set to indicate the error.

What is subprocess Popen?

The subprocess module defines one class, Popen and a few wrapper functions that use that class. The constructor for Popen takes arguments to set up the new process so the parent can communicate with it via pipes. It provides all of the functionality of the other modules and functions it replaces, and more.

Does Popen need to be closed?

Popen do we need to close the connection or subprocess automatically closes the connection? Usually, the examples in the official documentation are complete. There the connection is not closed. So you do not need to close most probably.


1 Answers

You can use the "not yet official" boost.process if you want an object-oriented approach for managing the subprocess.

Or you can just use popen itself, if you don't mind the C-ness of it all.

like image 95
Stephen Avatar answered Oct 11 '22 16:10

Stephen