Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2008-10

TAsyncProcess.OnTerminate doesn't fire

6 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Tom Lisjac

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.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;

Reply by email

Micha Nelissen
to Tom Lisjac
Tom Lisjac wrote 5 lines
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.

What Widgetset are you using?

You should not use poWaitOnExit because that basically destroys the idea of asynchronous ;-).

Micha

Reply by email

Tom Lisjac
to Micha Nelissen
Micha Nelissen wrote 8 lines
Tom Lisjac wrote: > 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. What Widgetset are you using?

I'm using the default gtk on Linux and an svn from Sept 14th.

You should not use poWaitOnExit because that basically destroys the idea of asynchronous ;-).

I would agree if OnTerminate was working... otherwise how does the app know that the async process has completed? :)

I've also noticed that without poWaitOnExit, the processes die and leave zombies in the process tree:

root 2356 0.0 0.0 0 0 ? Z 12:09 0:00 [ls] <defunct> root 2357 0.0 0.0 0 0 ? Z 12:09 0:00 [ls] <defunct> root 2358 0.0 0.0 0 0 ? Z 12:09 0:00 [ls] <defunct> root 2359 0.0 0.0 0 0 ? Z 12:09 0:00 [ls] <defunct>

I haven't decided if I can live with this in the final version and may have to give up on the async feature. Although zombies are harmless, hundreds of them attached to the Lazarus parent may look a little scary to tech aware end users.

The zombies are a minor issue, however. Knowing when the async process terminates is the part of the puzzle I don't have as yet.

Thanks for the reply.

-Tom

Reply by email

Micha Nelissen
to Tom Lisjac
Tom Lisjac wrote 7 lines
I haven't decided if I can live with this in the final version and may have to give up on the async feature. Although zombies are harmless, hundreds of them attached to the Lazarus parent may look a little scary to tech aware end users. The zombies are a minor issue, however. Knowing when the async process terminates is the part of the puzzle I don't have as yet.

Ah you also need to:

Index: interfaces/gtk/gtkdefines.inc
=================================================================== --- interfaces/gtk/gtkdefines.inc (revision 14070) +++ interfaces/gtk/gtkdefines.inc (working copy) @@ -10,7 +10,7 @@

  {$IFNDEF DisableAsyncProcess}
    {$IFDEF Linux}
      {$IFDEF CPUI386}

- {off $DEFINE UseAsyncProcess}
+ {$DEFINE UseAsyncProcess}

      {$ENDIF}
    {$ENDIF}
  {$ENDIF}

Micha

Reply by email

Tom Lisjac
to Micha Nelissen

That fixed both issues... OnTerminate is firing and I can turn off poWaitOnExit without seeing zombies in the process tree.

Thanks Micha!

-Tom

Show quoted text 25 lines
> The zombies are a minor issue, however. Knowing when the async process > terminates is the part of the puzzle I don't have as yet. Ah you also need to: Index: interfaces/gtk/gtkdefines.inc =================================================================== --- interfaces/gtk/gtkdefines.inc (revision 14070) +++ interfaces/gtk/gtkdefines.inc (working copy) @@ -10,7 +10,7 @@ {$IFNDEF DisableAsyncProcess} {$IFDEF Linux} {$IFDEF CPUI386} - {off $DEFINE UseAsyncProcess} + {$DEFINE UseAsyncProcess} {$ENDIF} {$ENDIF} {$ENDIF} Micha _______________________________________________ Lazarus mailing list http://www.lazarus.freepascal.org/mailman/listinfo/lazarus

Reply by email

Tom Lisjac
to Micha Nelissen: Ah you also need to: Index: interfaces/gtk/gtkdefines.inc…

Small remaining problem. :)

- {off $DEFINE UseAsyncProcess} + {$DEFINE UseAsyncProcess}

The executable works perfectly, but since making this change, gdb seems to terminate immediately when trying to run the app in the IDE. Same behavior with the older gtk default from Sept 14th and the nice looking gtk2 svn as of yesterday. If I back out the change, the debugger works again.

Thanks,

-Tom

Reply by email