mirror of
https://gitlab.com/freepascal.org/lazarus/lazarus.git
synced 2025-08-16 09:39:09 +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
|
type
|
||||||
TAsyncProcess = class(TProcess)
|
TAsyncProcess = class(TProcess)
|
||||||
private
|
private
|
||||||
|
FHookedPipeHandle: THandle;
|
||||||
FOnReadData: TNotifyEvent;
|
FOnReadData: TNotifyEvent;
|
||||||
FOnTerminate: TNotifyEvent;
|
FOnTerminate: TNotifyEvent;
|
||||||
protected
|
protected
|
||||||
@ -66,7 +67,7 @@ end;
|
|||||||
|
|
||||||
uses BaseUnix, TermIO;
|
uses BaseUnix, TermIO;
|
||||||
|
|
||||||
{$ifdef DARWIN}
|
{$ifdef BSD}
|
||||||
const
|
const
|
||||||
FIONREAD = $4004667;
|
FIONREAD = $4004667;
|
||||||
{$endif}
|
{$endif}
|
||||||
@ -89,7 +90,10 @@ end;
|
|||||||
procedure TAsyncProcess.HandlePipeInput(AData: PtrInt; AReasons: TPipeReasons);
|
procedure TAsyncProcess.HandlePipeInput(AData: PtrInt; AReasons: TPipeReasons);
|
||||||
begin
|
begin
|
||||||
if prBroken in AReasons then
|
if prBroken in AReasons then
|
||||||
RemovePipeEventHandler(Output.Handle);
|
begin
|
||||||
|
RemovePipeEventHandler(FHookedPipeHandle);
|
||||||
|
FHookedPipeHandle := 0;
|
||||||
|
end;
|
||||||
if prDataAvailable in AReasons then
|
if prDataAvailable in AReasons then
|
||||||
if FOnReadData <> nil then
|
if FOnReadData <> nil then
|
||||||
FOnReadData(Self);
|
FOnReadData(Self);
|
||||||
@ -98,7 +102,11 @@ end;
|
|||||||
procedure TAsyncProcess.HandleProcessTermination(AData: PtrInt; AReason: TChildExitReason; AInfo: dword);
|
procedure TAsyncProcess.HandleProcessTermination(AData: PtrInt; AReason: TChildExitReason; AInfo: dword);
|
||||||
begin
|
begin
|
||||||
RemoveProcessEventHandler(ProcessHandle);
|
RemoveProcessEventHandler(ProcessHandle);
|
||||||
RemovePipeEventHandler(Output.Handle);
|
if FHookedPipeHandle <> 0 then
|
||||||
|
begin
|
||||||
|
RemovePipeEventHandler(FHookedPipeHandle);
|
||||||
|
FHookedPipeHandle := 0;
|
||||||
|
end;
|
||||||
if FOnTerminate <> nil then
|
if FOnTerminate <> nil then
|
||||||
FOnTerminate(Self);
|
FOnTerminate(Self);
|
||||||
end;
|
end;
|
||||||
@ -108,7 +116,10 @@ begin
|
|||||||
inherited;
|
inherited;
|
||||||
|
|
||||||
if poUsePipes in Options then
|
if poUsePipes in Options then
|
||||||
AddPipeEventHandler(Output.Handle, @HandlePipeInput, 0);
|
begin
|
||||||
|
FHookedPipeHandle := Output.Handle;
|
||||||
|
AddPipeEventHandler(FHookedPipeHandle, @HandlePipeInput, 0);
|
||||||
|
end;
|
||||||
AddProcessEventHandler(ProcessHandle, @HandleProcessTermination, 0);
|
AddProcessEventHandler(ProcessHandle, @HandleProcessTermination, 0);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ var
|
|||||||
threadsync_giochannel: pgiochannel;
|
threadsync_giochannel: pgiochannel;
|
||||||
childsig_pending: boolean;
|
childsig_pending: boolean;
|
||||||
|
|
||||||
{$ifdef DARWIN}
|
{$ifdef BSD}
|
||||||
procedure ChildEventHandler(sig: longint; var siginfo: tsiginfo_t;
|
procedure ChildEventHandler(sig: longint; var siginfo: tsiginfo_t;
|
||||||
var sigcontext: sigcontextrec); cdecl;
|
var sigcontext: sigcontextrec); cdecl;
|
||||||
{$else}
|
{$else}
|
||||||
|
Loading…
Reference in New Issue
Block a user