I need to open a subprocess using popen, the process will constantly ask for user input ... The main process should send this data through the channel.
This is my first attempt:
FILE *in; char buff[1024]; if(!(in = popen("cd FIX/fix2/src; java -cp .:./* com.fix.bot", "w"))){ return 1; } while(1){ char buffer[] = { 'x' }; fwrite(buffer, sizeof(char), sizeof(buffer), in); cout << "Wrote!" << endl; usleep(1000000); }
However, the data is not sent! I need to close the pipe using pclose () so that data is written to the process. How can I ensure that data is recorded without having to close the pipe every time?
source share