mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-04-22 16:39:26 +02:00
all of BSD seems to use different signal handler type
make TAsyncProcess a little more robust git-svn-id: trunk@8296 -
This commit is contained in:
parent
634147ddfb
commit
23faec7e80
@ -33,6 +33,7 @@ uses
|
||||
type
|
||||
TAsyncProcess = class(TProcess)
|
||||
private
|
||||
FHookedPipeHandle: THandle;
|
||||
FOnReadData: TNotifyEvent;
|
||||
FOnTerminate: TNotifyEvent;
|
||||
protected
|
||||
@ -66,7 +67,7 @@ end;
|
||||
|
||||
uses BaseUnix, TermIO;
|
||||
|
||||
{$ifdef DARWIN}
|
||||
{$ifdef BSD}
|
||||
const
|
||||
FIONREAD = $4004667;
|
||||
{$endif}
|
||||
@ -89,7 +90,10 @@ end;
|
||||
procedure TAsyncProcess.HandlePipeInput(AData: PtrInt; AReasons: TPipeReasons);
|
||||
begin
|
||||
if prBroken in AReasons then
|
||||
RemovePipeEventHandler(Output.Handle);
|
||||
begin
|
||||
RemovePipeEventHandler(FHookedPipeHandle);
|
||||
FHookedPipeHandle := 0;
|
||||
end;
|
||||
if prDataAvailable in AReasons then
|
||||
if FOnReadData <> nil then
|
||||
FOnReadData(Self);
|
||||
@ -98,7 +102,11 @@ end;
|
||||
procedure TAsyncProcess.HandleProcessTermination(AData: PtrInt; AReason: TChildExitReason; AInfo: dword);
|
||||
begin
|
||||
RemoveProcessEventHandler(ProcessHandle);
|
||||
RemovePipeEventHandler(Output.Handle);
|
||||
if FHookedPipeHandle <> 0 then
|
||||
begin
|
||||
RemovePipeEventHandler(FHookedPipeHandle);
|
||||
FHookedPipeHandle := 0;
|
||||
end;
|
||||
if FOnTerminate <> nil then
|
||||
FOnTerminate(Self);
|
||||
end;
|
||||
@ -108,7 +116,10 @@ begin
|
||||
inherited;
|
||||
|
||||
if poUsePipes in Options then
|
||||
AddPipeEventHandler(Output.Handle, @HandlePipeInput, 0);
|
||||
begin
|
||||
FHookedPipeHandle := Output.Handle;
|
||||
AddPipeEventHandler(FHookedPipeHandle, @HandlePipeInput, 0);
|
||||
end;
|
||||
AddProcessEventHandler(ProcessHandle, @HandleProcessTermination, 0);
|
||||
end;
|
||||
|
||||
|
@ -137,7 +137,7 @@ var
|
||||
threadsync_giochannel: pgiochannel;
|
||||
childsig_pending: boolean;
|
||||
|
||||
{$ifdef DARWIN}
|
||||
{$ifdef BSD}
|
||||
procedure ChildEventHandler(sig: longint; var siginfo: tsiginfo_t;
|
||||
var sigcontext: sigcontextrec); cdecl;
|
||||
{$else}
|
||||
|
Loading…
Reference in New Issue
Block a user