Greetings!
So, I am using NSTask to run a command line tool from within my application. To read from the stdout, I'm using NSPipe and NSFileHandle.
The problem I'm bumping into is that I can't read from the stdout if the application runs into a scanf within the tool. All that ends up happening is the application blocks when I try to read the available data.
Code:
int main()
{
char myLetter;
printf("Type a letter> ");
scanf("%c", &myLetter);
}
I am aware that one can just send the data to the task via another pipe, and if I use that approach, the task works. Unfortunately, I want to have the user type in the input at runtime, which requires that they can see the printf and scanf statements coming from the task.
In other words, I am trying to have the user see the printed statement "Type a letter> ", have the user enter in a response, and proceed from there. (The actual sending of data is easy) The problem I'm having is that I don't know how to read from the task while it's waiting for input. In my current setup, I can't even see the printf statement. The program just blocks when I try to read data.
Any ideas on how to accomplish what I'm after?