Forum > General

[SOLVED]Launching multiple processes

(1/1)

BlueMoony:
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: ---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;
--- End code ---

However, in this way, it only launches 1 application. The others aren't started. It works when I use
--- Code: ---shellTerminal.Options := shellTerminal.Options + [poNewConsole];
--- End code ---
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

Leledumbo:

--- Quote from: BlueMoony on July 31, 2014, 06:58:59 pm ---Is there any way to start multiple processes without showing the consoles?

--- End quote ---
try poNewConsole in process options, swoHIDE is show window.

--- Quote from: BlueMoony on July 31, 2014, 06:58:59 pm ---PS: the opstion poNoConsole doesn't work together with the poNewConsole

--- End quote ---
Certainly, what do you expect?

BlueMoony:
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?
--- End quote ---

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

Leledumbo:
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:

--- Quote from: Leledumbo on July 31, 2014, 10:44:51 pm ---Can you set [] to all process' options? Just to make sure the first app doesn't block execution of the rest.

--- End quote ---

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!

Navigation

[0] Message Index

Go to full version