Recent

Author Topic: [SOLVED]Launching multiple processes  (Read 4270 times)

BlueMoony

  • New Member
  • *
  • Posts: 34
[SOLVED]Launching multiple processes
« on: July 31, 2014, 06:58:59 pm »
Hello dear Lazarus community,

as I am trying to launch external programs using the TProcess object, I stumbled upon a few problems.
I am in need to launch several programs. I've got one controlling program which starts without any visible window (called Controller). This controller should launch several other executables which do have a form to show. They have to be launched all around the same time and I need to kill/start new whenever I want to. I want to do it this way instead of using threads because the OS itself will do the scheduling of the processes so that's not my concern.

Now, I create an array with specific objects. These objects all have their own TProcess object. I create it like this:

Code: [Select]
var
  shellTerminal: TProcess;
begin
  try
    shellTerminal:= TProcess.Create(nil);
    shellTerminal.Executable:= '/bin/sh';
    shellTerminal.Parameters.Add('-c');
    shellTerminal.Parameters.Add(_appLocation + _appName + ' ' + ParamString);
    ShowMessage(_appLocation + _appName + ' ' + ParamString);
    shellTerminal.Execute;
    shellTerminal.Parameters.Clear;
  except
  end;

However, in this way, it only launches 1 application. The others aren't started. It works when I use
Code: [Select]
shellTerminal.Options := shellTerminal.Options + [poNewConsole]; but then there is this ugly console AND the form visible (I only want the form to be visible).

Is there any way to start multiple processes without showing the consoles?

PS: the opstion poNoConsole doesn't work together with the poNewConsole

Thanks in advance,

BlueMoony
« Last Edit: August 11, 2014, 09:53:35 pm by BlueMoony »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8777
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Launching multiple processes
« Reply #1 on: July 31, 2014, 10:02:44 pm »
Is there any way to start multiple processes without showing the consoles?
try poNewConsole in process options, swoHIDE is show window.
PS: the opstion poNoConsole doesn't work together with the poNewConsole
Certainly, what do you expect?

BlueMoony

  • New Member
  • *
  • Posts: 34
Re: Launching multiple processes
« Reply #2 on: July 31, 2014, 10:33:11 pm »
the swoHIDE option on the ShowWindow doesn't fix it either (Tried that already)

Quote
Quote from: BlueMoony on Today at 06:58:59 pm

    PS: the opstion poNoConsole doesn't work together with the poNewConsole

Certainly, what do you expect?

That I could ask the system to give me a new console which I do not have direct access to :) (= invisible)

My apologizes on not fully following the forum rules:
Lazarus version 1.0.12
FPC 2.6.2
x86_64_linux_gtk_2
« Last Edit: July 31, 2014, 10:37:06 pm by BlueMoony »

Leledumbo

  • Hero Member
  • *****
  • Posts: 8777
  • Programming + Glam Metal + Tae Kwon Do = Me
Re: Launching multiple processes
« Reply #3 on: July 31, 2014, 10:44:51 pm »
Sorry, I didn't notice that you're on Linux, therefore all console related options have no effect since every Linux application is basically a console application. Can you set [] to all process' options? Just to make sure the first app doesn't block execution of the rest.

BlueMoony

  • New Member
  • *
  • Posts: 34
Re: Launching multiple processes
« Reply #4 on: August 01, 2014, 09:49:10 am »
Can you set [] to all process' options? Just to make sure the first app doesn't block execution of the rest.

That seems to fix it. Can't get to it that I didn't try that before... So by default the poWaitOnExit is probably enabled.

Thanks for the quick reply and solution!

 

TinyPortal © 2005-2018