Unable to capture command line output via pipe using TAsyncProcess on Mac
Original Reporter info from Mantis: fangqq
-
Reporter name: Qianqian Fang
Original Reporter info from Mantis: fangqq
- Reporter name: Qianqian Fang
Description:
I use a TAsyncProcess to call an external console program and capture/print the output. This works fine on Linux/Windows, but I found it fails on the Mac.
Steps to reproduce:
The sample code to reproduce this bug is attached. I tested on two different mac machines, both have the same output.
The sample contains a simple GUI, user type a shell command, and the TAsyncProcess capture the output via pipes, and print it in a TMemo.
I tried typing "ls -l", "pwd", or "whoami", none of these returned any output. The OnReadData event was never triggered.
When I tried "mkdir ~/testdir", the folder was indeed created, so I suppose the command may got launched, but the pipe were broken.
also want to add that, to run the test code on Linux, one needs to uncheck the "suoUseSize" under pMCX.StartupOptions. Otherwise, you can see an error message "unknown options '-g'" or '-e' (except type 'echo' as the command), this is due to the automatically appended "-geometry 0x0" parameter.
Additional information:
I posted my original question in these two threads
https://forum.lazarus.freepascal.org/index.php/topic,40593.0.html
https://forum.lazarus.freepascal.org/index.php/topic,40630.0.html
one of the users suggested TProcess, I tested, TProcess does work, and return the output. However, it does not allow me to interactively communicate with the external program.
I do think this is a bug for TAsyncProcess on the Mac.
A workaround is appreciated!
Mantis conversion info:
- Mantis ID: 33537
- OS: OSX
- OS Build: high Sierra
- Platform: Mac
- Version: 1.8.2