|
@@ -53,7 +53,11 @@ end;
|
|
//function SIGCHLDHandler(Sig: longint): longint; cdecl;//this is std linux C declaration as function
|
|
//function SIGCHLDHandler(Sig: longint): longint; cdecl;//this is std linux C declaration as function
|
|
procedure SIGCHLDHandler(Sig: longint); cdecl;
|
|
procedure SIGCHLDHandler(Sig: longint); cdecl;
|
|
begin
|
|
begin
|
|
|
|
+ {$ifdef ver1_0}
|
|
waitpid(-1, nil, WNOHANG);
|
|
waitpid(-1, nil, WNOHANG);
|
|
|
|
+ {$else}
|
|
|
|
+ fpwaitpid(-1, nil, WNOHANG);
|
|
|
|
+ {$endif}
|
|
end;
|
|
end;
|
|
|
|
|
|
const zeroset :sigset = (0,0,0,0);
|
|
const zeroset :sigset = (0,0,0,0);
|
|
@@ -66,6 +70,7 @@ begin
|
|
ThreadsInited:=true;
|
|
ThreadsInited:=true;
|
|
|
|
|
|
|
|
|
|
|
|
+
|
|
// This will install SIGCHLD signal handler
|
|
// This will install SIGCHLD signal handler
|
|
// signal() installs "one-shot" handler,
|
|
// signal() installs "one-shot" handler,
|
|
// so it is better to install and set up handler with sigaction()
|
|
// so it is better to install and set up handler with sigaction()
|
|
@@ -83,7 +88,11 @@ begin
|
|
Act^.sa_flags := SA_NOCLDSTOP {or SA_NOMASK or SA_RESTART};
|
|
Act^.sa_flags := SA_NOCLDSTOP {or SA_NOMASK or SA_RESTART};
|
|
//Do not block all signals ??. Don't need if SA_NOMASK in flags
|
|
//Do not block all signals ??. Don't need if SA_NOMASK in flags
|
|
|
|
|
|
- SigAction(SIGCHLD, Act, OldAct);
|
|
|
|
|
|
+ {$ifdef ver1_0}
|
|
|
|
+ SigAction(SIGCHLD, @Act, @OldAct);
|
|
|
|
+ {$else}
|
|
|
|
+ fpsigaction(SIGCHLD, @Act, @OldAct);
|
|
|
|
+ {$endif}
|
|
|
|
|
|
FreeMem(Act, SizeOf(SigActionRec));
|
|
FreeMem(Act, SizeOf(SigActionRec));
|
|
FreeMem(OldAct, SizeOf(SigActionRec));
|
|
FreeMem(OldAct, SizeOf(SigActionRec));
|
|
@@ -162,7 +171,7 @@ begin
|
|
Thread.DoTerminate;
|
|
Thread.DoTerminate;
|
|
if FreeThread then
|
|
if FreeThread then
|
|
Thread.Free;
|
|
Thread.Free;
|
|
- ExitProcess(Result);
|
|
|
|
|
|
+ fpExit(Result);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -195,7 +204,7 @@ begin
|
|
WaitFor;
|
|
WaitFor;
|
|
end;
|
|
end;
|
|
if FHandle <> -1 then
|
|
if FHandle <> -1 then
|
|
- Kill(FHandle, SIGKILL);
|
|
|
|
|
|
+ {$ifdef ver1_0}kill({$else}fpkill({$endif}FHandle, SIGKILL);
|
|
dec(FStackPointer,FStackSize);
|
|
dec(FStackPointer,FStackSize);
|
|
Freemem(pointer(FStackPointer),FStackSize);
|
|
Freemem(pointer(FStackPointer),FStackSize);
|
|
inherited Destroy;
|
|
inherited Destroy;
|
|
@@ -226,7 +235,11 @@ var
|
|
P: Integer;
|
|
P: Integer;
|
|
I: TThreadPriority;
|
|
I: TThreadPriority;
|
|
begin
|
|
begin
|
|
- P := {$ifdef ver1_0}Linux{$else}Unix{$endif}.GetPriority(Prio_Process,FHandle);
|
|
|
|
|
|
+ P := {$ifdef ver1_0}
|
|
|
|
+ Linux.getpriority
|
|
|
|
+ {$else}
|
|
|
|
+ Unix.fpGetPriority
|
|
|
|
+ {$endif} (Prio_Process,FHandle);
|
|
Result := tpNormal;
|
|
Result := tpNormal;
|
|
for I := Low(TThreadPriority) to High(TThreadPriority) do
|
|
for I := Low(TThreadPriority) to High(TThreadPriority) do
|
|
if Priorities[I] = P then
|
|
if Priorities[I] = P then
|
|
@@ -236,7 +249,11 @@ end;
|
|
|
|
|
|
procedure TThread.SetPriority(Value: TThreadPriority);
|
|
procedure TThread.SetPriority(Value: TThreadPriority);
|
|
begin
|
|
begin
|
|
- {$ifdef ver1_0}Linux{$else}Unix{$endif}.SetPriority(Prio_Process,FHandle, Priorities[Value]);
|
|
|
|
|
|
+ {$ifdef ver1_0}
|
|
|
|
+ Linux.Setpriority
|
|
|
|
+ {$else}
|
|
|
|
+ Unix.fpSetPriority
|
|
|
|
+ {$endif} (Prio_Process,FHandle, Priorities[Value]);
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
@@ -262,14 +279,14 @@ end;
|
|
|
|
|
|
procedure TThread.Suspend;
|
|
procedure TThread.Suspend;
|
|
begin
|
|
begin
|
|
- Kill(FHandle, SIGSTOP);
|
|
|
|
|
|
+ {$ifdef ver1_0}kill({$else}fpkill({$endif}FHandle, SIGSTOP);
|
|
FSuspended := true;
|
|
FSuspended := true;
|
|
end;
|
|
end;
|
|
|
|
|
|
|
|
|
|
procedure TThread.Resume;
|
|
procedure TThread.Resume;
|
|
begin
|
|
begin
|
|
- Kill(FHandle, SIGCONT);
|
|
|
|
|
|
+ {$ifdef ver1_0}kill({$else}fpkill({$endif}FHandle, SIGCONT);
|
|
FSuspended := False;
|
|
FSuspended := False;
|
|
end;
|
|
end;
|
|
|
|
|
|
@@ -283,16 +300,26 @@ function TThread.WaitFor: Integer;
|
|
var
|
|
var
|
|
status : longint;
|
|
status : longint;
|
|
begin
|
|
begin
|
|
|
|
+{$ifdef ver1_0}
|
|
if FThreadID = MainThreadID then
|
|
if FThreadID = MainThreadID then
|
|
WaitPid(0,@status,0)
|
|
WaitPid(0,@status,0)
|
|
else
|
|
else
|
|
WaitPid(FHandle,@status,0);
|
|
WaitPid(FHandle,@status,0);
|
|
|
|
+{$else}
|
|
|
|
+ if FThreadID = MainThreadID then
|
|
|
|
+ fpWaitPid(0,@status,0)
|
|
|
|
+ else
|
|
|
|
+ fpWaitPid(FHandle,@status,0);
|
|
|
|
+{$endif}
|
|
Result:=status;
|
|
Result:=status;
|
|
end;
|
|
end;
|
|
|
|
|
|
{
|
|
{
|
|
$Log$
|
|
$Log$
|
|
- Revision 1.9 2003-01-17 19:01:07 marco
|
|
|
|
|
|
+ Revision 1.10 2003-09-20 12:38:29 marco
|
|
|
|
+ * FCL now compiles for FreeBSD with new 1.1. Now Linux.
|
|
|
|
+
|
|
|
|
+ Revision 1.9 2003/01/17 19:01:07 marco
|
|
* small fix
|
|
* small fix
|
|
|
|
|
|
Revision 1.8 2002/11/17 21:09:44 marco
|
|
Revision 1.8 2002/11/17 21:09:44 marco
|