Tom Lisjac
2008-10-11 06:23:28 UTC
The TAsyncProcess option set in the test code below executes and
terminates without leaving a zombie process, but the OnTerminate event
never fires. I've tried a variety of options including just
[poUsePipes,poStderrToOutPut] but have yet to see the OnTerminate
event.
Have I set up this component correctly, or is this a bug?
Thanks,
-Tom
------------
Procedure Tform1.Formcreate(Sender: Tobject);
Begin
Asyncprocess1.OnReadData:=@Readprocdata;
Asyncprocess1.OnTerminate:=@Procterminate;
Asyncprocess1.Options:=Asyncprocess1.Options+[poWaitOnExit,poUsePipes,poStderrToOutPut,poNoconsole,poNewProcessGroup];
End;
Procedure Tform1.Button1click(Sender: Tobject);
Begin
with Asyncprocess1 do
begin
commandline:='ls -la';
currentdirectory:='/tmp';
execute
end;
End;
Procedure Tform1.Readprocdata(Sender: Tobject);
begin
with sender as TAsyncProcess do
begin
edit1.text:=inttostr(NumBytesAvailable);
Memo1.Lines.LoadFromStream(OutPut);
end
End;
Procedure Tform1.Procterminate(Sender: Tobject);
Begin
edit2.text:='async done';
End;
terminates without leaving a zombie process, but the OnTerminate event
never fires. I've tried a variety of options including just
[poUsePipes,poStderrToOutPut] but have yet to see the OnTerminate
event.
Have I set up this component correctly, or is this a bug?
Thanks,
-Tom
------------
Procedure Tform1.Formcreate(Sender: Tobject);
Begin
Asyncprocess1.OnReadData:=@Readprocdata;
Asyncprocess1.OnTerminate:=@Procterminate;
Asyncprocess1.Options:=Asyncprocess1.Options+[poWaitOnExit,poUsePipes,poStderrToOutPut,poNoconsole,poNewProcessGroup];
End;
Procedure Tform1.Button1click(Sender: Tobject);
Begin
with Asyncprocess1 do
begin
commandline:='ls -la';
currentdirectory:='/tmp';
execute
end;
End;
Procedure Tform1.Readprocdata(Sender: Tobject);
begin
with sender as TAsyncProcess do
begin
edit1.text:=inttostr(NumBytesAvailable);
Memo1.Lines.LoadFromStream(OutPut);
end
End;
Procedure Tform1.Procterminate(Sender: Tobject);
Begin
edit2.text:='async done';
End;