Recent

Author Topic: [SOLVED] Tprocess freeze  (Read 428 times)

bourbon

  • New Member
  • *
  • Posts: 11
[SOLVED] Tprocess freeze
« on: November 07, 2024, 09:53:26 am »
Linux Mint 20.1
AMD Ryzen 5 3600
Lazarus (2.0.6)
Grisbi (1.2.2)

Hello,
I want to be able to launch grisbi from a program that:
- asks for and verifies a password
- launches the execution of the grisbi program

To launch the execution of grisbi, I go through a TProcess.
The grisbi program launches well, but its menus are frozen, and it is impossible to close the application.
Running the task manager does not kill the process. Indeed, it too is completely frozen.

Code: Pascal  [Select][+][-]
  1. procedure TForm1.Btn_OKClick(Sender: TObject);
  2. var
  3. AProcess: TProcess;
  4. begin
  5.   if (Edt_PassWord.Text = 'password')
  6.     then
  7.   begin
  8.     AProcess := TProcess.Create(nil);
  9.     AProcess.CommandLine := 'grisbi /mnt/sdb5/Oud/Places/Grisbi/mon_grisbi.gsb';
  10.     AProcess.Options := AProcess.Options + [poWaitOnExit];  // menus bloqués
  11.     AProcess.Execute;
  12.     AProcess.free;
  13.     //Application.Terminate;
  14.    end
  15.   else
  16.   begin
  17.    showmessage('Mot de passe invalide');
  18.    WCtr := WCtr + 1;
  19.    Edt_Password.Text := '';
  20.    Edt_Password.SetFocus;
  21.  end;
  22.    if (WCtr = 3) then  Application.Terminate
  23.    else abort;
  24. end;          
« Last Edit: November 07, 2024, 01:58:55 pm by bourbon »

Thaddy

  • Hero Member
  • *****
  • Posts: 16201
  • Censorship about opinions does not belong here.
Re: Tprocess freeze
« Reply #1 on: November 07, 2024, 10:07:04 am »
https://www.freepascal.org/docs-html/fcl/process/tprocess.options.html
I would add poUsePipes and poWaitOnExit to process options. That may be enough.
If I smell bad code it usually is bad code and that includes my own code.

bourbon

  • New Member
  • *
  • Posts: 11
Re: Tprocess freeze
« Reply #2 on: November 07, 2024, 12:06:41 pm »
OK, I will try and let you know. Thanks.
Edit :
Code: Pascal  [Select][+][-]
  1.  AProcess.Options := AProcess.Options + [poWaitOnExit, poUsePipes];
Don't change anything, still with the menu blocked
« Last Edit: November 07, 2024, 12:10:41 pm by bourbon »

marcov

  • Administrator
  • Hero Member
  • *
  • Posts: 11951
  • FPC developer.
Re: Tprocess freeze
« Reply #3 on: November 07, 2024, 12:37:49 pm »
Programs that provide security related prompts sometimes resist automation.

Maybe it is simply a setuid binary. Try executing it over a/the shell.

bourbon

  • New Member
  • *
  • Posts: 11
Re: Tprocess freeze
« Reply #4 on: November 07, 2024, 01:58:23 pm »
There you go, it works well  :D

Code: Pascal  [Select][+][-]
  1.     begin
  2.       AProcess := TProcess.Create(nil);
  3.       AProcess.Executable := 'grisbi';
  4.       Aprocess.Parameters.Add('/mnt/sdb5/Oud/Places/Grisbi/mon_grisbi.gsb');
  5.       AProcess.Options := AProcess.Options + [poWaitOnExit,poUsePipes];  // menus bloqués
  6.       AProcess.Execute;
  7.       AStringList.Free;
  8.       AProcess.free;
  9.       Application.Terminate;
  10.     end    

Thaddy

  • Hero Member
  • *****
  • Posts: 16201
  • Censorship about opinions does not belong here.
Re: [SOLVED] Tprocess freeze
« Reply #5 on: November 07, 2024, 04:31:25 pm »
( I knew that, I am not stupid on purpose and I test..)  %)
Nice that it works.
If I smell bad code it usually is bad code and that includes my own code.

 

TinyPortal © 2005-2018