user2992269
user2992269

Reputation:

Runnig process with proc_open

I have one php script and I want to call a process writting in C from the PHP scrit. There are many ways to do it(system,exec...), but Ï chosse the function proc_open. With this I can open a pipe in stdin and stdout with the C process, but I don´t know how to get the data from stdin in the C process. Can anyone help me with a example?.Thank you

Upvotes: 0

Views: 135

Answers (1)

Claudi
Claudi

Reputation: 5416

In C, stdin, stdout and stderr are constant FILE pointers defined in <stdio.h>. For example, to read from stdin:

#include <stdio.h>

int main() {
    int ch = fgetc(stdin); //read 1 character from stdin
    fputc(ch, stdout);  //dump to stdout
    //...
    return 0;
}

Upvotes: 1

Related Questions