Add option to TProcess to hold console after process is finished
Original Reporter info from Mantis: dusan.halicky
-
Reporter name:
Original Reporter info from Mantis: dusan.halicky
- Reporter name:
Description:
There is poNewConsole in TProcess.Options. But when I execute something that finish very fast I don't see what it was. I use it on both linux and windows and I managed to modify process.pas/.inc to suit my needs. I added new option poHoldConsole and when this option is set, on linux I add "-hold" parameter to xterm, and on windows I prepend "cmd /K " before TProcess.CommandLine. Both modifications are in attachment.
Modified lines for linux version:
if poHoldConsole in P.Options then
S.Insert(0,'-hold');
Modified lines for windows version:
if (poHoldConsole in Options)and(FCommandLine <> '') then
FCommandLine := 'cmd.exe /K '+FCommandLine;
As you can see, it is quite simple. I'm not sure if there are some other problems with this solution. Full source is in attachment.
Steps to reproduce:
// source for modified TProcess for linux and windows is in attachment
p := TProcess.Create;
p.Options := p.Options + [poNewConsole, poHoldConsole];
p.CommandLine := 'echo Hello';
p.Execute;
Mantis conversion info:
- Mantis ID: 22302
- Version: 2.4.2
- Monitored by: » dusan.halicky (dusan.halicky)