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.