From: Henry N. <hen...@ar...> - 2010-01-30 19:35:50
|
On 28.01.2010 20:41, Frank Church wrote: > I am using Lazarus/FreePascal to run a coLinux VM but the shutdown > process just seems to terminate it abruptly and I would like to know > if there is some other way. > > eg when you close click on the close button of a coLinux terminal > window, it prints out a yellow notice and goes through a controlled > shutdown process. In my case when I close from the Lazarus app, the > window disappears abruptly, and I wonder if goes through a controlled > shutdown. > > The start process is like this. > > vmProcess := TProcess.Create > vmProcess.CommandLine := 'c:\colinux\coLinux-daemon.exe -k -t NT -d > @rt.conf'; > vmProcess.Execute; > ShowMessage('process pid = ' + IntToStr(vmProcess.ProcessID)); > > The ccommand to close is like this. > > if Assigned(vmProcess) then > begin > vmProcess.Active := False; > vmProcess.Free; > end; > > Is there some value I can derive from the ProcesID than I can use to > send a message to windows to close it properly? I'm not a user of Pascal. I think, you killed the process to shortly after Active := False with the Free of this object. http://lazarus-ccr.sourceforge.net/docs/fcl/process/tprocess.execute.html I would say, you needs to use "Terminate" and than check "Running" in a time limited loop with some idle time for the CPU, to let the process gracefully shutting down. Last get the exit code with WaitOnExit. -- Henry N. |