Execute the program from the C program

How should I run another program from my C program? I need to be able to write data to the STDIN of the started program (and possibly read from its STDOUT)

I am not sure if this is a standard C function. I need to run under Linux Solution.

you want to use popen. It provides you with a one-way pipeline, you You can use it to access the stdin and stdout of the program.

Popen is the standard configuration of modern unix and unix-like operating systems, and Linux is one of them:-)

Type

man popen

Read more related information in the terminal.

Edit

popen Whether to generate one-way or two-way pipes depends on the implementation. In Linux and OpenBSD, popen generates one-way pipes, which are read-only or write-only. On OS X, FreeBSD and NetBSD, popen produces two-way pipes.

How should I run another program from my C program? I need to be able to write data to the STDIN of the started program (and possibly read from its STDOUT)

I am not sure if this is a standard C function. I need to run under Linux The solution.

You want to use popen. It provides you with a one-way pipe, you can use it to access the program’s stdin and stdout. < p>

Popen is the standard configuration of modern unix and unix-like operating systems, and Linux is one of them:-)

Type

man popen

Read more information in the terminal.

Edit

Whether popen generates one-way or two-way pipes depends on the implementation. In Linux and OpenBSD, popen generates one-way pipes, which are read-only or write-only. On OS X, FreeBSD and NetBSD, popen produces two-way pipes.

Leave a Comment

Your email address will not be published.