showing console program output in GUI app lazarus / 32-Linux ---------------------------------------------------------------------- Martin V · 2016-08-06 16:16 I have managed to redirect the output of a console program via named pipes to my gui app and to print it to a memo field. On Windows, I have used the Windows API functions: - CreateNamedPipe - ConnectNamedPipe - I have run the console program synchronous via cmd.exe in an own thread, by using >pipename behind the command line parameters - after running the external program, a 300 ms sleep in the main thread to get the time which is necessary to receive the rest of the output - DisConnectNamedPipe in the own thread - in the main thead a loop with ReadFile which gets exited if ReadFile results an error or 0 bytes read. Meanwhile, the code works fine. But the named pipes concept seems to be very different in Linux, I have not found any platform-independent code in Freepascal/Lazarus for named pipes. There are only few API calls. Which are the correct Unix API calls? (I also plan to create my program on Mac OS) ? Thank you for any hint. ---------------------------------------------------------------------- User137 · 2016-08-06 16:22 Maybe TProcess can do the same? I think that sort of general purpose class would be made cross-platform. http://www.freepascal.org/docs-html/fcl/process/tprocess.input.html or http://www.freepascal.org/docs-html/fcl/process/tprocess.output.html ---------------------------------------------------------------------- Phil · 2016-08-06 16:27 Quote from: User137 on August 06, 2016, 06:22:36 pmMaybe TProcess can do the same? Martin, What he said. I would scrap that entire approach and just use TProcess to run the console app and capture its output. The "300 ms sleep" sounds like a failure waiting to happen. And doesn't that kind of defeat the purpose of running the console app in a separate thread if you're waiting for it to complete? The Win API calls will likely tie your code to Windows. Start over would be my suggestion. -Phil ---------------------------------------------------------------------- Martin V · 2016-08-06 19:11 Thank you for the tProcess.Output hint. This page holds an explanation and a sample code: http://wiki.freepascal.org/Executing_External_Programs#Reading_large_o utput