I use gdb to get some debug information in the program.

I enter into the terminal "gdb gs", then there is some processing. When processing is completed climbs out (gdb), they say we are waiting, you can enter the command further.
There is a code:
ProcessStartInfo psi = new ProcessStartInfo(); psi.FileName = "gdb"; psi.Arguments = "gs"; psi.RedirectStandardOutput = true; psi.RedirectStandardInput = true; psi.UseShellExecute = false; Process p = Process.Start(psi); while (!p.StandardOutput.EndOfStream) { string _out = p.StandardOutput.ReadLine(); Console.WriteLine(_out); if (обработка завершена) p.StandardInput.WriteLine("info variables"); } In the while loop, each new line is read as it arrives, the last line "... done." I don’t get any new lines anymore, there’s no "(gdb)" line, so the waiting continues in the loop. The problem is that I do not know how to understand when the processing was completed. You can check the end of the line, if "done.", Then continue, but it does not fit. It is necessary to receive event of appearance "(gdb)".