-
Content Count
2268 -
Joined
-
Last visited
-
Days Won
46
Everything posted by Fr0sT.Brutal
-
Generics: Classes vs Records - Differences in use
Fr0sT.Brutal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
Ah yes right I haven't noticed the getter returning pointer to array item. In my record list class I use dynamically allocated records and store pointers only so have no such issues. -
1-sec googling: https://wiki.delphi-jedi.org/wiki/JVCL_Help:TJvCreateProcess that claims to have CDir setting. I could suggest my implementation but it's somewhat tied to other util units. Anyway there's nothing hard in launching (code is NOT standalone - some additional utils required) // Launch a process with I/O redirect. // @param ExecProps - requisites for launch // @param [OUT] Handles - in / out pipe handles, process handle // @raises Exception on error procedure ExecProcess(const ExecProps: TExecProps; out Handles: THandleArr); var si: TStartupInfo; pi: TProcessInformation; sa: TSecurityAttributes; hStdOut, hStdIn, hStdErr: THandle; IntCmdLine, IntCurrDir, Env: string; begin Handles := Default(THandleArr); hStdOut := 0; hStdIn := 0; hStdErr := 0; si := Default(TStartupInfo); pi := Default(TProcessInformation); try try // TSecurityAttributes для процесса и труб sa := Default(TSecurityAttributes); sa.nLength := SizeOf(sa); sa.lpSecurityDescriptor := nil; sa.bInheritHandle := True; // create pipes if needed // ! We can't simply override only some of handles - https://stackoverflow.com/questions/30494945 // But assigning standard values with GetStdHandle results in weird behavior // (I/O error on ReadLn specifying standard STDIN, weird hangs etc). // As the situation when STDIN is required in executed process but not redirected // will unlikely happen, just set the handle to NULL. // As for output pipes, create and redirect them always to avoid bugs. // STDIN if pStdIn in ExecProps.RedirectPipes then begin if not CreatePipe(hStdIn, Handles[ehStdIn], @sa, PipeBufSize) then raise LastOSErr('CreatePipe'); // Ensure the write handle to the pipe for STDIN is not inherited (from MSDN example) SetHandleInformation(Handles[ehStdIn], HANDLE_FLAG_INHERIT, 0); end; // STDOUT // if pStdOut in ExecProps.RedirectPipes then begin if not CreatePipe(Handles[ehStdOut], hStdOut, @sa, PipeBufSize) then raise LastOSErr('CreatePipe'); // Ensure the read handle to the pipe for STDOUT is not inherited (from MSDN example) SetHandleInformation(Handles[ehStdOut], HANDLE_FLAG_INHERIT, 0); end; // STDERR // if pStdErr in ExecProps.RedirectPipes then begin if not CreatePipe(Handles[ehStdErr], hStdErr, @sa, PipeBufSize) then raise LastOSErr('CreatePipe'); // Ensure the read handle to the pipe for STDERR is not inherited (from MSDN example) SetHandleInformation(Handles[ehStdErr], HANDLE_FLAG_INHERIT, 0); end; si.cb := SizeOf(si); si.dwFlags := STARTF_USESHOWWINDOW; if ExecProps.RedirectPipes <> [] then si.dwFlags := si.dwFlags or STARTF_USESTDHANDLES; si.wShowWindow := SW_HIDE; si.hStdInput := hStdIn; si.hStdOutput := hStdOut; si.hStdError := hStdErr; if ExecProps.CurrDir = '' then IntCurrDir := GetCurrentDir else IntCurrDir := ExecProps.CurrDir; // Construct a new env from an old one with addition of that given in parameters and // error signature. Env := StrArrToEnv(ExecProps.EnvVars) + GetEnv + #0; IntCmdLine := ExecProps.CmdLine; // command line MUST be modifyable - CreateProcessW requirement UniqueString(IntCmdLine); if not CreateProcess(nil, PChar(IntCmdLine), @sa, nil, True, {} // show window CREATE_NEW_CONSOLE{$IFDEF UNICODE} or CREATE_UNICODE_ENVIRONMENT{$ENDIF}, PChar(Env), PChar(IntCurrDir), si, pi) then raise LastOSErr('CreateProcess', GetLastError, '"'+IntCmdLine+'"'); Handles[ehProcess] := pi.hProcess; // Set priority if not default if ExecProps.Priority <> NORMAL_PRIORITY_CLASS then SetPriorityClass(Handles[ehProcess], ExecProps.Priority); except CloseHandles(Handles); raise; end; finally // Free thread handles and unneeded pipe ends CloseAndZeroHandle(hStdIn); CloseAndZeroHandle(hStdOut); CloseAndZeroHandle(hStdErr); CloseAndZeroHandle(pi.hThread); end; end;
-
Actually I'm not as I use my own app launcher with STDIN/OUT redirection. I have an app running 24/7 for months that constantly launches external apps (archiver and some others) without any issue. Btw, your problem looks very alike to resource leakage. You can check if there are non-disposed resources with ProcessExplorer -> Opened handles
-
Generics: Classes vs Records - Differences in use
Fr0sT.Brutal replied to Lars Fosdal's topic in Algorithms, Data Structures and Class Design
Why not? -
What is wrong with TStringList
Fr0sT.Brutal replied to pyscripter's topic in RTL and Delphi Object Pascal
No problem, that subject was interesting and useful as well. But talking about ideal stringlist, what features do you need really? I've never felt I miss something in SL's for many years of Delphi using. -
And again the topic has turned to some other direction 😉
-
There's WMI component in my Awesome list. No idea for Linux
-
No idea. Maybe JVCL implementation would perform better?
-
Invalid Compiler Directive: 'MESSAGES'
Fr0sT.Brutal replied to Incus J's topic in ICS - Internet Component Suite
Well, I have several 24/7 network apps that I'd make console or service if I were starting them now. And as we're slowly moving to Linux, it's very common for it to have no GUI at all on servers -
I doubt it. In this very case most of these features are specific for editor application. Others won't even notice troubles.
-
Should Exit be used instead of 'record Exists?' boolean?
Fr0sT.Brutal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
As for me, everywhere I need search in arrays, I use generic classes or wrappers. Of course, if I have an array and need finding an item in just one place, I don't implement separate functions @dummzeuch, @Remy Lebeau good point though I prefer separating the methods -
Should Exit be used instead of 'record Exists?' boolean?
Fr0sT.Brutal replied to Mike Torrettinni's topic in Algorithms, Data Structures and Class Design
In my practice if I made Find* methods first, later I always came to situation when I also needed the index of the item found. So I had to add IndexOf method and then use it in Find* methods. Why not doing this from the start 🙂 -
Invalid Compiler Directive: 'MESSAGES'
Fr0sT.Brutal replied to Incus J's topic in ICS - Internet Component Suite
Could FMX message queue be used in console applications? -
Issues Deploying Firebird DB on Ubuntu 8.04LTS
Fr0sT.Brutal replied to Larry Hengen's topic in Cross-platform
Very informative ))) DAC guys rock! I'd recommend you to try opening DB from Firebird's own tool ISQL (on Linux it's called isql-fb). Thus you can ensure the DB is really accessible. -
List of packages used by a project
Fr0sT.Brutal replied to Javier Tarí's topic in Delphi IDE and APIs
Hmm, section "requires" in package.dpk? -
Issues Deploying Firebird DB on Ubuntu 8.04LTS
Fr0sT.Brutal replied to Larry Hengen's topic in Cross-platform
+1. Just copy DB file to another location. Do you really need connecting to DB locally? -
Use of Ansistring in Unicode world?
Fr0sT.Brutal replied to Mike Torrettinni's topic in General Help
Ah, THAT Andy )) David really puzzled me! -
I apparently saw some expert allowing to exclude some properties from saved DFM... maybe CnPack? I haven't tried too much experts so if not GExperts then it should be CnPack
-
Use of Ansistring in Unicode world?
Fr0sT.Brutal replied to Mike Torrettinni's topic in General Help
Comment about inefficiency of Unicode strings? Ok, I read it, what that nonsense should have told me? -
Use of Ansistring in Unicode world?
Fr0sT.Brutal replied to Mike Torrettinni's topic in General Help
If you care about performance so much, you can use if Ord(c) in [Ord('A')..Ord('Z')] or case c of 'A'..'Z': ... end; -
+1 for adding the CB-related forum IF there will be someone with knowledge. Major part of 'Delphi' is IDE+RTL+VCL which are common with CB. Moreover, as CB has been a poor brother of Delphi for long time, many things fluent with Delphi still raise issues with CB.
-
Invalid Compiler Directive: 'MESSAGES'
Fr0sT.Brutal replied to Incus J's topic in ICS - Internet Component Suite
It seems so http://docwiki.embarcadero.com/RADStudio/Sydney/en/What's_New#Key_FireMonkey_Platform_Enhancements -
None. You can use categories [Category('bench')] procedure BenchMsgThreads; [Category('stability')] procedure TestMsgThreadStab; and corresponding arguments
-
where can I get general git process questions answered?
Fr0sT.Brutal replied to David Schwartz's topic in General Help
Very likely that everyone will tell you to RTFM first (true gitters are severe unixoids that don't like to mess with noobs). There are tons of manuals everywhere. Probably you could try generic IT discussion boards for non-concrete subjects. Maybe Reddit (haven't used it myself though) -
Storage box in a bank xD