Recent

Author Topic: Unable to capture command line output from TAsyncProcess - Lazarus 1.8.2 on Mac  (Read 3558 times)

FangQ

  • Full Member
  • ***
  • Posts: 134
I use a TAsyncProcess to call an external program and capture/print the output. This works fine on Linux/Windows, but recently I found it fails on the Mac (remember it worked before on Lazarus 1.6, but I upgraded to 1.8.2 recently).

Here is the code segment for reading the command line output.

https://github.com/fangq/mcx/blob/master/mcxstudio/mcxgui.pas#L2136-L2162

does anyone notice the same? any workaround would be appreciated.

Phil

  • Hero Member
  • *****
  • Posts: 2737
I use a TAsyncProcess to call an external program and capture/print the output. This works fine on Linux/Windows, but recently I found it fails on the Mac (remember it worked before on Lazarus 1.6, but I upgraded to 1.8.2 recently).

Here is the code segment for reading the command line output.

https://github.com/fangq/mcx/blob/master/mcxstudio/mcxgui.pas#L2136-L2162

does anyone notice the same? any workaround would be appreciated.

Post a small example of how TAsyncProcess fails. You don't say how it fails and you don't say what you were trying to run. There are many reasons why running an external program might fail.

FangQ

  • Full Member
  • ***
  • Posts: 134
Post a small example of how TAsyncProcess fails. You don't say how it fails and you don't say what you were trying to run. There are many reasons why running an external program might fail.

a small example is attached, I tried to let the TAsyncProcess to run simple commands such as "ls -l" or "pwd" or "whoami", nothing prints.

Please let me know if you can replicate this issue, and suggest any workaround. This works fine on Linux and windows.

I want to also add that I tried both lazarus 1.8.2 and 1.6.4 on Mac (Sierra 10.12.6) and saw the same empty output.
« Last Edit: March 23, 2018, 09:48:07 pm by FangQ »

FangQ

  • Full Member
  • ***
  • Posts: 134
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.

on the Mac, nothing was printed - the TAsyncProcess.onReadData is never fired. If there is something wrong, I would at least expect to see error messages, but none was printed (the TAsyncProcess.Options.poStderrToOutPut is enabled in the component, actually, error messages are printed on Linux).

 

TinyPortal © 2005-2018