tags:

views:

98

answers:

1

I'm implementing a compiler in my Compilers class, I'm using Qt & C++.

After I have generated the machine code from the source code, I'm executing the virtual machine that will execute the code.

I'm facing a problem here, I'm using readyRead() signal to get output from the virtual machine, but how can I know that the virtual machine wants to read data from the user?

I wanna show the user an input dialog each time the machine asks for input.

A: 

Actually input stream of the process is designed in the way it's not necessary to be real user input. For example if you are redirecting file to the input of your application you have nobody to ask for next portion of input. In this case when you call std::cin >> a there are no signal generated by application or operation system and QProcess doesn't have any way to know that child application is waiting for input.

My suggestion is to use some of simple IPC like anonymous pipes to notify parent process about such events. If it's possible you can use use some specific markup in child process standard output to send such notifications.

If virtual machine you are running is third party application then I think parsing its output searching something informing user that some input is required is the only option.

VestniK