Recent

Author Topic: [False][3.3] RunCommand not return outputstring  (Read 611 times)

Zaher

  • Hero Member
  • *****
  • Posts: 600
    • parmaja.com
[False][3.3] RunCommand not return outputstring
« on: May 02, 2020, 04:19:11 am »
In Windows 8.1 i am testing (also win10), in fpc 3.3.1 Getting output of console project by using TProcess, It hang on reading from pipe, to test it just use RunCommand with small exe (you can build pascal with hello world), it hang and without result of output string.
while it is work find in fpc 3.0.4

Please test it and confirm maybe I am wrong.

After digging in process.pp of 3.3.1, I found the problem in
Code: [Select]
Function GetCreationFlags(P : TProcessnamemacro) : Cardinal;

begin
  With P do
    begin
    Result:=CREATE_UNICODE_ENVIRONMENT;
    if poNoConsole in Options then
      Result:=Result or CREATE_NO_WINDOW; <- here
    if poNewConsole in Options then
      Result:=Result or Create_new_console;
    if poNewProcessGroup in Options then
      Result:=Result or CREATE_NEW_PROCESS_GROUP;
    If poRunSuspended in Options Then
      Result:=Result or Create_Suspended;
    if poDebugProcess in Options Then
      Result:=Result or DEBUG_PROCESS;
    if poDebugOnlyThisProcess in Options Then
      Result:=Result or DEBUG_ONLY_THIS_PROCESS;
    if poDefaultErrorMode in Options Then
      Result:=Result or CREATE_DEFAULT_ERROR_MODE;
    result:=result or PriorityConstants[FProcessPriority];
    end;
end;

Code: [Select]
    if poNoConsole in Options then
      Result:=Result or CREATE_NO_WINDOW;

in 3.0.4 it is DETACHED_PROCESS , replacing  CREATE_NO_WINDOW with DETACHED_PROCESS solves the probelm
Code: [Select]
    if poNoConsole in Options then
      Result:=Result or DETACHED_PROCESS;

Please test before reporting a bug
« Last Edit: May 02, 2020, 07:02:22 pm by Zaher »

Bi0T1N

  • Jr. Member
  • **
  • Posts: 50
Re: [3.3] RunCommand not return outputstring
« Reply #1 on: May 02, 2020, 10:17:34 am »
I didn't test it but the change was done because of #32055.
I assume your problem is due to missing setup of the standard handles with the changed flag: "Therefore, the console handle for the application is not set."

Zaher

  • Hero Member
  • *****
  • Posts: 600
    • parmaja.com
Re: [3.3] RunCommand not return outputstring
« Reply #2 on: May 02, 2020, 03:54:19 pm »
Ok, I am doing more test

Zaher

  • Hero Member
  • *****
  • Posts: 600
    • parmaja.com
Re: [False][3.3] RunCommand not return outputstring
« Reply #3 on: May 02, 2020, 07:15:17 pm »
RunCommand works prefect today, maybe my brain exhausted yesterday, but still have a problem with my project that make backup for PostgreSQL using 'pg_dump.exe' that worked perfect with FPC 3.0.4

pg_dump write 'password' then my project respond the password through Input pipe handle.

In 3.3 never read any from pg_dump, but when i replaced it with fake pg_dump (wrote it in pascal) , my project read it,
It is a problem then in pg_dump, but this problem solved if i used DETACHED_PROCESS.

Bi0T1N

  • Jr. Member
  • **
  • Posts: 50
Re: [False][3.3] RunCommand not return outputstring
« Reply #4 on: May 02, 2020, 08:01:11 pm »
The reason for that is probably the newly used CREATE_NO_WINDOW flag which doesn't setup the console handles like STDIN/STDOUT/STDERR and thus the RunCommand doesn't see the 'output' from pg_dump.
I'd suggest to create a bug report as this seems to be a regression (if not explicitly documented in the wiki).

Zaher

  • Hero Member
  • *****
  • Posts: 600
    • parmaja.com
Re: [False][3.3] RunCommand not return outputstring
« Reply #5 on: May 02, 2020, 09:56:57 pm »
While It is special case for pg_dumb, (and maybe some other projects like it) I am thinking to ask by feature request to add DETACHED_PROCESS as DETACHED_PROCESS as poDetached flag.

this a useful article Exact meaning of console creation flags

marcov

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 8729
  • FPC developer.
Re: [False][3.3] RunCommand not return outputstring
« Reply #6 on: May 02, 2020, 10:06:41 pm »
r45228


 

TinyPortal © 2005-2018