TProcess cannot execute a command
Original Reporter info from Mantis: ggeldenhuys
-
Reporter name: Graeme Geldenhuys
Original Reporter info from Mantis: ggeldenhuys
- Reporter name: Graeme Geldenhuys
Description:
This email describes the issue.
----------[ forward ]----------------
Mattias Gaertner wrote:
On Thu, 27 Aug 2009 11:23:52 +0200
Graeme Geldenhuys &LtPos;graemeg@opensoft.homeip.net> wrote:
Hi,
As far as I know, Lazarus doesn't have a Thread List Window available.
So I am trying to setup and external tools menu item which will do
this for me, but I am have some problems with it.
This is the actual setup strings used for the external tool.
Program Filename:
/usr/bin/gnome-terminal
Parameters:
--title="Thread Monitor - $NameOnly($TargetFile())" --command="watch
-n.1 'ps -C $NameOnly($TargetFile()) -L -o pid,tid,pcpu,state'"
When I run Lazarus from the command line under Linux, this is the
output shown to stdout when I try and run my external tool.
[TExternalToolList.Run] CmdLine="/usr/bin/gnome-terminal
--title="Thread Monitor - project1" --command="watch -n.1 'ps -C
project1 -L -o pid,tid,pcpu,state'"" WorkDir=""
As far as I can see the macros used in the External Tool step was
converted correctly. I can even copy and paste the CmdLine without the
outer quotes and it executes fine from a teminal window. Yet, if I run
it from the Tools menu gnome-terminal gives an error. The error is:
"There was an error creating the child process for this terminal"
Anybody know what I am doing wrong?
It is a bug in fcl-process/src/unix/process.inc proc CommandToList
used by TProcess.
It only removes the outer ".
Please report it.
Mattias
--------------------------
I even tried putting my command in a executable shell script as shown below, and that did not work either.
----------[ ~/bin/lsthreads ]------------------ /usr/bin/gnome-terminal --title="Thread Monitor" \ --command="watch -n.1 'ps -C ${1} -L -o pid,tid,pcpu,state'" ----------------[ end ]------------------
and here is a small test project...
--------[ small test program ]-------------
program project1;
{$mode objfpc}{$H+}
uses
Classes, process;
var
t: TProcess;
sl: TStringList;
begin
t := TProcess.Create(nil);
t.Options := [poWaitOnExit];
// this gives an error
// t.CommandLine := '/usr/bin/gnome-terminal --title="Thread Monitor - project1" --command="watch -n.1 ''ps -C project1 -L -o pid,tid,pcpu,state''" ';
// this doesn't show anything
t.CommandLine := 'lsthreads lazarus';
// this one works
//t.CommandLine := 'top';
t.Execute;
writeln('Press <ENTER> to continue...');
readln;
t.Free;
end.
--------------[ end ]-------------------
Mantis conversion info:
- Mantis ID: 14446
- OS: Ubuntu Linux 9.04
- Build: r13573
- Platform: x86_64 & i386
- Version: 2.3.1
- Fixed in version: 2.6.0
- Fixed in revision: 17379 (#49cf3958)
- Monitored by: » @michaliskambi (Michalis Kamburelis)
- Target version: 2.6.0