mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-14 20:09:27 +02:00
* update so it can be compiled by both 1.0.x and 1.1
This commit is contained in:
parent
a820a0f393
commit
f2b653319b
@ -32,7 +32,12 @@ uses
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Unix;
|
{$ifdef ver1_0}
|
||||||
|
linux
|
||||||
|
{$else}
|
||||||
|
unix
|
||||||
|
{$endif}
|
||||||
|
;
|
||||||
|
|
||||||
{ OS - independent class implementations are in /inc directory. }
|
{ OS - independent class implementations are in /inc directory. }
|
||||||
{$i classes.inc}
|
{$i classes.inc}
|
||||||
@ -50,7 +55,10 @@ finalization
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 2001-01-21 20:45:09 marco
|
Revision 1.4 2001-04-08 11:26:03 peter
|
||||||
|
* update so it can be compiled by both 1.0.x and 1.1
|
||||||
|
|
||||||
|
Revision 1.3 2001/01/21 20:45:09 marco
|
||||||
* Rename fest II FCL version.
|
* Rename fest II FCL version.
|
||||||
|
|
||||||
Revision 1.2 2000/10/26 22:30:21 peter
|
Revision 1.2 2000/10/26 22:30:21 peter
|
||||||
|
@ -14,7 +14,13 @@
|
|||||||
|
|
||||||
**********************************************************************}
|
**********************************************************************}
|
||||||
|
|
||||||
uses Unix;
|
uses
|
||||||
|
{$ifdef ver1_0}
|
||||||
|
Linux
|
||||||
|
{$else}
|
||||||
|
Unix
|
||||||
|
{$endif}
|
||||||
|
;
|
||||||
|
|
||||||
Function TProcess.GetRunning : Boolean;
|
Function TProcess.GetRunning : Boolean;
|
||||||
|
|
||||||
@ -42,10 +48,10 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
CreatePipeStreams (FParentErrorStream,FChildErrorStream);
|
CreatePipeStreams (FParentErrorStream,FChildErrorStream);
|
||||||
If FCurrentDirectory<>'' then
|
If FCurrentDirectory<>'' then
|
||||||
Chdir(FCurrentDirectory);
|
Chdir(FCurrentDirectory);
|
||||||
FHandle:=fork();
|
FHandle:=fork();
|
||||||
if FHandle=0 then
|
if FHandle=0 then
|
||||||
begin
|
begin
|
||||||
// Child
|
// Child
|
||||||
fdClose(0);
|
fdClose(0);
|
||||||
@ -54,14 +60,14 @@ begin
|
|||||||
dup2(FChildInputStream.Handle,0);
|
dup2(FChildInputStream.Handle,0);
|
||||||
dup2(FCHildOutputStream.Handle,1);
|
dup2(FCHildOutputStream.Handle,1);
|
||||||
dup2(FChildErrorStream.Handle,2);
|
dup2(FChildErrorStream.Handle,2);
|
||||||
execl(FCommandline);
|
execl(FCommandline);
|
||||||
halt(127);
|
halt(127);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
// Parent
|
// Parent
|
||||||
FPID:=FHandle;
|
FPID:=FHandle;
|
||||||
FThreadHandle:=FHandle;
|
FThreadHandle:=FHandle;
|
||||||
fdclose(FChildOutputStream.Handle);
|
fdclose(FChildOutputStream.Handle);
|
||||||
fdclose(FChildInputStream.Handle);
|
fdclose(FChildInputStream.Handle);
|
||||||
fdclose(FChildErrorStream.Handle);
|
fdclose(FChildErrorStream.Handle);
|
||||||
@ -106,7 +112,10 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 2001-01-21 20:45:09 marco
|
Revision 1.4 2001-04-08 11:26:03 peter
|
||||||
|
* update so it can be compiled by both 1.0.x and 1.1
|
||||||
|
|
||||||
|
Revision 1.3 2001/01/21 20:45:09 marco
|
||||||
* Rename fest II FCL version.
|
* Rename fest II FCL version.
|
||||||
|
|
||||||
Revision 1.2 2000/10/26 22:30:21 peter
|
Revision 1.2 2000/10/26 22:30:21 peter
|
||||||
|
@ -217,7 +217,7 @@ var
|
|||||||
P: Integer;
|
P: Integer;
|
||||||
I: TThreadPriority;
|
I: TThreadPriority;
|
||||||
begin
|
begin
|
||||||
P := Unix.GetPriority(Prio_Process,FHandle);
|
P := {$ifdef ver1_0}Linux{$else}Unix{$endif}.GetPriority(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
|
||||||
@ -227,7 +227,7 @@ end;
|
|||||||
|
|
||||||
procedure TThread.SetPriority(Value: TThreadPriority);
|
procedure TThread.SetPriority(Value: TThreadPriority);
|
||||||
begin
|
begin
|
||||||
Unix.SetPriority(Prio_Process,FHandle, Priorities[Value]);
|
{$ifdef ver1_0}Linux{$else}Unix{$endif}.SetPriority(Prio_Process,FHandle, Priorities[Value]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -283,7 +283,10 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 2001-01-21 20:45:09 marco
|
Revision 1.4 2001-04-08 11:26:03 peter
|
||||||
|
* update so it can be compiled by both 1.0.x and 1.1
|
||||||
|
|
||||||
|
Revision 1.3 2001/01/21 20:45:09 marco
|
||||||
* Rename fest II FCL version.
|
* Rename fest II FCL version.
|
||||||
|
|
||||||
Revision 1.2 2000/10/26 22:30:21 peter
|
Revision 1.2 2000/10/26 22:30:21 peter
|
||||||
|
@ -43,10 +43,10 @@ type
|
|||||||
FSocketOptions : TSocketOptions;
|
FSocketOptions : TSocketOptions;
|
||||||
Procedure GetSockOptions;
|
Procedure GetSockOptions;
|
||||||
Procedure SetSocketOptions(Value : TSocketOptions);
|
Procedure SetSocketOptions(Value : TSocketOptions);
|
||||||
Public
|
Public
|
||||||
Constructor Create (AHandle : Longint);virtual;
|
Constructor Create (AHandle : Longint);virtual;
|
||||||
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
function Seek(Offset: Longint; Origin: Word): Longint; override;
|
||||||
Property SocketOptions : TSocketOptions Read FSocketOptions
|
Property SocketOptions : TSocketOptions Read FSocketOptions
|
||||||
Write SetSocketOptions;
|
Write SetSocketOptions;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ type
|
|||||||
TConnectQuery = Procedure (Sender : TObject; ASocket : Longint; Var Allow : Boolean) of Object;
|
TConnectQuery = Procedure (Sender : TObject; ASocket : Longint; Var Allow : Boolean) of Object;
|
||||||
|
|
||||||
TSocketServer = Class(TObject)
|
TSocketServer = Class(TObject)
|
||||||
Private
|
Private
|
||||||
FOnIdle : TNotifyEvent;
|
FOnIdle : TNotifyEvent;
|
||||||
FNonBlocking : Boolean;
|
FNonBlocking : Boolean;
|
||||||
FSocket : longint;
|
FSocket : longint;
|
||||||
@ -65,7 +65,7 @@ type
|
|||||||
FOnConnect : TConnectEvent;
|
FOnConnect : TConnectEvent;
|
||||||
FOnConnectQuery : TConnectQuery;
|
FOnConnectQuery : TConnectQuery;
|
||||||
Procedure DoOnIdle;
|
Procedure DoOnIdle;
|
||||||
Protected
|
Protected
|
||||||
FSockType : Longint;
|
FSockType : Longint;
|
||||||
FBound : Boolean;
|
FBound : Boolean;
|
||||||
Procedure DoConnect(ASocket : TSocketStream); Virtual;
|
Procedure DoConnect(ASocket : TSocketStream); Virtual;
|
||||||
@ -74,7 +74,7 @@ type
|
|||||||
Function Accept: Longint;Virtual;Abstract;
|
Function Accept: Longint;Virtual;Abstract;
|
||||||
Function SockToStream (ASocket : Longint) : TSocketStream;Virtual;Abstract;
|
Function SockToStream (ASocket : Longint) : TSocketStream;Virtual;Abstract;
|
||||||
Procedure Close; Virtual;
|
Procedure Close; Virtual;
|
||||||
Public
|
Public
|
||||||
Constructor Create(ASocket : Longint);
|
Constructor Create(ASocket : Longint);
|
||||||
Destructor Destroy; Override;
|
Destructor Destroy; Override;
|
||||||
Procedure Listen;
|
Procedure Listen;
|
||||||
@ -91,7 +91,7 @@ type
|
|||||||
Property Socket : Longint Read FSocket;
|
Property Socket : Longint Read FSocket;
|
||||||
Property SockType : Longint Read FSockType;
|
Property SockType : Longint Read FSockType;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TInetServer = Class(TSocketServer)
|
TInetServer = Class(TSocketServer)
|
||||||
Protected
|
Protected
|
||||||
FAddr : TINetSockAddr;
|
FAddr : TINetSockAddr;
|
||||||
@ -103,9 +103,9 @@ type
|
|||||||
Procedure Bind; Override;
|
Procedure Bind; Override;
|
||||||
Property Port : Word Read FPort;
|
Property Port : Word Read FPort;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TUnixServer = Class(TSocketServer)
|
TUnixServer = Class(TSocketServer)
|
||||||
Private
|
Private
|
||||||
FUnixAddr : TUnixSockAddr;
|
FUnixAddr : TUnixSockAddr;
|
||||||
FFileName : String;
|
FFileName : String;
|
||||||
Protected
|
Protected
|
||||||
@ -116,26 +116,26 @@ type
|
|||||||
Constructor Create(AFileName : String);
|
Constructor Create(AFileName : String);
|
||||||
Procedure Bind; Override;
|
Procedure Bind; Override;
|
||||||
Property FileName : String Read FFileName;
|
Property FileName : String Read FFileName;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TInetSocket = Class(TSocketStream)
|
TInetSocket = Class(TSocketStream)
|
||||||
Private
|
Private
|
||||||
FHost : String;
|
FHost : String;
|
||||||
FPort : Word;
|
FPort : Word;
|
||||||
Protected
|
Protected
|
||||||
Procedure DoConnect(ASocket : longint); Virtual;
|
Procedure DoConnect(ASocket : longint); Virtual;
|
||||||
Public
|
Public
|
||||||
Constructor Create(ASocket : longint); Override;
|
Constructor Create(ASocket : longint); Override;
|
||||||
Constructor Create(const AHost: String; APort: Word);
|
Constructor Create(const AHost: String; APort: Word);
|
||||||
Property Host : String Read FHost;
|
Property Host : String Read FHost;
|
||||||
Property Port : Word Read FPort;
|
Property Port : Word Read FPort;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
TUnixSocket = Class(TSocketStream)
|
TUnixSocket = Class(TSocketStream)
|
||||||
Private
|
Private
|
||||||
FFileName : String;
|
FFileName : String;
|
||||||
Protected
|
Protected
|
||||||
Procedure DoConnect(ASocket : longint); Virtual;
|
Procedure DoConnect(ASocket : longint); Virtual;
|
||||||
Public
|
Public
|
||||||
Constructor Create(ASocket : Longint);
|
Constructor Create(ASocket : Longint);
|
||||||
Constructor Create(AFileName : String);
|
Constructor Create(AFileName : String);
|
||||||
@ -144,13 +144,29 @@ type
|
|||||||
|
|
||||||
Implementation
|
Implementation
|
||||||
|
|
||||||
uses inet,Unix;
|
uses
|
||||||
|
{$ifdef linux}
|
||||||
|
{$ifdef ver1_0}
|
||||||
|
Linux,
|
||||||
|
{$else}
|
||||||
|
Unix,
|
||||||
|
{$endif}
|
||||||
|
{$endif}
|
||||||
|
{$ifdef freebsd}
|
||||||
|
{$ifdef ver1_0}
|
||||||
|
Linux,
|
||||||
|
{$else}
|
||||||
|
Unix,
|
||||||
|
{$endif}
|
||||||
|
{$endif}
|
||||||
|
inet
|
||||||
|
;
|
||||||
|
|
||||||
Const
|
Const
|
||||||
SocketWouldBlock = -2;
|
SocketWouldBlock = -2;
|
||||||
|
|
||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
ESocketError
|
ESocketError
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
resourcestring
|
resourcestring
|
||||||
@ -161,7 +177,7 @@ resourcestring
|
|||||||
strSocketConnectFailed = 'Connect to %s failed.';
|
strSocketConnectFailed = 'Connect to %s failed.';
|
||||||
strSocketAcceptFailed = 'Could not accept a client connection: %s';
|
strSocketAcceptFailed = 'Could not accept a client connection: %s';
|
||||||
strSocketAcceptWouldBlock = 'Accept would block on socket: %d';
|
strSocketAcceptWouldBlock = 'Accept would block on socket: %d';
|
||||||
|
|
||||||
constructor ESocketError.Create(ACode: TSocketErrorType; const MsgArgs: array of const);
|
constructor ESocketError.Create(ACode: TSocketErrorType; const MsgArgs: array of const);
|
||||||
var
|
var
|
||||||
s: String;
|
s: String;
|
||||||
@ -203,13 +219,13 @@ end;
|
|||||||
Function TSocketStream.Seek(Offset: Longint; Origin: Word): Longint;
|
Function TSocketStream.Seek(Offset: Longint; Origin: Word): Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Result:=0;
|
Result:=0;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
TSocketServer
|
TSocketServer
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
Constructor TSocketServer.Create(ASocket : Longint);
|
Constructor TSocketServer.Create(ASocket : Longint);
|
||||||
|
|
||||||
begin
|
begin
|
||||||
@ -228,7 +244,7 @@ Procedure TSocketServer.Close;
|
|||||||
begin
|
begin
|
||||||
If FSocket<>-1 Then
|
If FSocket<>-1 Then
|
||||||
FileClose(FSocket);
|
FileClose(FSocket);
|
||||||
FSocket:=-1;
|
FSocket:=-1;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TSocketServer.Listen;
|
Procedure TSocketServer.Listen;
|
||||||
@ -246,12 +262,12 @@ Var
|
|||||||
NoConnections,
|
NoConnections,
|
||||||
NewSocket : longint;
|
NewSocket : longint;
|
||||||
Stream : TSocketStream;
|
Stream : TSocketStream;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Listen;
|
Listen;
|
||||||
Repeat
|
Repeat
|
||||||
Repeat
|
Repeat
|
||||||
Try
|
Try
|
||||||
NewSocket:=Accept;
|
NewSocket:=Accept;
|
||||||
If NewSocket>=0 then
|
If NewSocket>=0 then
|
||||||
begin
|
begin
|
||||||
@ -270,9 +286,9 @@ begin
|
|||||||
NewSocket:=-1;
|
NewSocket:=-1;
|
||||||
end;
|
end;
|
||||||
else
|
else
|
||||||
Raise;
|
Raise;
|
||||||
end;
|
end;
|
||||||
Until (NewSocket>=0) or (Not NonBlocking);
|
Until (NewSocket>=0) or (Not NonBlocking);
|
||||||
Until Not (FAccepting) or ((FMaxConnections<>-1) and (NoConnections>=FMaxConnections));
|
Until Not (FAccepting) or ((FMaxConnections<>-1) and (NoConnections>=FMaxConnections));
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -285,7 +301,7 @@ end;
|
|||||||
Procedure TSocketServer.DoOnIdle;
|
Procedure TSocketServer.DoOnIdle;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
If Assigned(FOnIdle) then
|
If Assigned(FOnIdle) then
|
||||||
FOnIdle(Self);
|
FOnIdle(Self);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
@ -324,20 +340,20 @@ begin
|
|||||||
S:=Sockets.Socket(AF_INET,SOCK_STREAM,0);
|
S:=Sockets.Socket(AF_INET,SOCK_STREAM,0);
|
||||||
If S=-1 Then
|
If S=-1 Then
|
||||||
Raise ESocketError.Create(seCreationFailed,[Format('%d',[APort])]);
|
Raise ESocketError.Create(seCreationFailed,[Format('%d',[APort])]);
|
||||||
Inherited Create(S);
|
Inherited Create(S);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
Procedure TInetServer.Bind;
|
Procedure TInetServer.Bind;
|
||||||
|
|
||||||
|
|
||||||
begin
|
begin
|
||||||
Faddr.family := AF_INET;
|
Faddr.family := AF_INET;
|
||||||
Faddr.port := ShortHostToNet(FPort);
|
Faddr.port := ShortHostToNet(FPort);
|
||||||
Faddr.addr := 0;
|
Faddr.addr := 0;
|
||||||
if not Sockets.Bind(FSocket, FAddr, Sizeof(FAddr)) then
|
if not Sockets.Bind(FSocket, FAddr, Sizeof(FAddr)) then
|
||||||
raise ESocketError.Create(seBindFailed, [IntToStr(FPort)]);
|
raise ESocketError.Create(seBindFailed, [IntToStr(FPort)]);
|
||||||
FBound:=True;
|
FBound:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TInetServer.SockToStream (ASocket : Longint) : TSocketStream;
|
Function TInetServer.SockToStream (ASocket : Longint) : TSocketStream;
|
||||||
@ -356,7 +372,7 @@ begin
|
|||||||
L:=SizeOf(FAddr);
|
L:=SizeOf(FAddr);
|
||||||
Result:=Sockets.Accept(Socket,Faddr,L);
|
Result:=Sockets.Accept(Socket,Faddr,L);
|
||||||
If Result<0 then
|
If Result<0 then
|
||||||
If SocketError=Sys_EWOULDBLOCK then
|
If SocketError=Sys_EWOULDBLOCK then
|
||||||
Raise ESocketError.Create(seAcceptWouldBlock,[socket])
|
Raise ESocketError.Create(seAcceptWouldBlock,[socket])
|
||||||
else
|
else
|
||||||
Raise ESocketError.Create(seAcceptFailed,[socket]);
|
Raise ESocketError.Create(seAcceptFailed,[socket]);
|
||||||
@ -365,36 +381,36 @@ end;
|
|||||||
{ ---------------------------------------------------------------------
|
{ ---------------------------------------------------------------------
|
||||||
TUnixServer
|
TUnixServer
|
||||||
---------------------------------------------------------------------}
|
---------------------------------------------------------------------}
|
||||||
|
|
||||||
Constructor TUnixServer.Create(AFileName : String);
|
Constructor TUnixServer.Create(AFileName : String);
|
||||||
|
|
||||||
Var S : Longint;
|
Var S : Longint;
|
||||||
|
|
||||||
begin
|
begin
|
||||||
FFileName:=AFileName;
|
FFileName:=AFileName;
|
||||||
S:=Sockets.Socket(AF_UNIX,SOCK_STREAM,0);
|
S:=Sockets.Socket(AF_UNIX,SOCK_STREAM,0);
|
||||||
If S=-1 then
|
If S=-1 then
|
||||||
Raise ESocketError.Create(seCreationFailed,[AFileName])
|
Raise ESocketError.Create(seCreationFailed,[AFileName])
|
||||||
else
|
else
|
||||||
Inherited Create(S);
|
Inherited Create(S);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TUnixServer.Close;
|
Procedure TUnixServer.Close;
|
||||||
begin
|
begin
|
||||||
Inherited Close;
|
Inherited Close;
|
||||||
DeleteFile(FFileName);
|
DeleteFile(FFileName);
|
||||||
FFileName:='';
|
FFileName:='';
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Procedure TUnixServer.Bind;
|
Procedure TUnixServer.Bind;
|
||||||
|
|
||||||
var
|
var
|
||||||
AddrLen : longint;
|
AddrLen : longint;
|
||||||
begin
|
begin
|
||||||
Str2UnixSockAddr(FFilename,FUnixAddr,AddrLen);
|
Str2UnixSockAddr(FFilename,FUnixAddr,AddrLen);
|
||||||
If Not Sockets.Bind(Socket,FUnixAddr,AddrLen) then
|
If Not Sockets.Bind(Socket,FUnixAddr,AddrLen) then
|
||||||
Raise ESocketError.Create(seBindFailed,[FFileName]);
|
Raise ESocketError.Create(seBindFailed,[FFileName]);
|
||||||
FBound:=True;
|
FBound:=True;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Function TUnixServer.Accept : Longint;
|
Function TUnixServer.Accept : Longint;
|
||||||
@ -405,7 +421,7 @@ begin
|
|||||||
L:=Length(FFileName);
|
L:=Length(FFileName);
|
||||||
Result:=Sockets.Accept(Socket,FUnixAddr,L);
|
Result:=Sockets.Accept(Socket,FUnixAddr,L);
|
||||||
If Result<0 then
|
If Result<0 then
|
||||||
If SocketError=Sys_EWOULDBLOCK then
|
If SocketError=Sys_EWOULDBLOCK then
|
||||||
Raise ESocketError.Create(seAcceptWouldBlock,[socket])
|
Raise ESocketError.Create(seAcceptWouldBlock,[socket])
|
||||||
else
|
else
|
||||||
Raise ESocketError.Create(seAcceptFailed,[socket]);
|
Raise ESocketError.Create(seAcceptFailed,[socket]);
|
||||||
@ -427,7 +443,7 @@ Constructor TInetSocket.Create(ASocket : Longint);
|
|||||||
begin
|
begin
|
||||||
Inherited Create(ASocket);
|
Inherited Create(ASocket);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Constructor TInetSocket.Create(const AHost: String; APort: Word);
|
Constructor TInetSocket.Create(const AHost: String; APort: Word);
|
||||||
|
|
||||||
Var
|
Var
|
||||||
@ -470,7 +486,7 @@ Constructor TUnixSocket.Create(ASocket : Longint);
|
|||||||
begin
|
begin
|
||||||
Inherited Create(ASocket);
|
Inherited Create(ASocket);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
Constructor TUnixSocket.Create(AFileName : String);
|
Constructor TUnixSocket.Create(AFileName : String);
|
||||||
|
|
||||||
Var S : Longint;
|
Var S : Longint;
|
||||||
@ -492,12 +508,15 @@ begin
|
|||||||
If Not Connect(ASocket,UnixAddr,AddrLen) then
|
If Not Connect(ASocket,UnixAddr,AddrLen) then
|
||||||
Raise ESocketError.Create(seConnectFailed,[FFilename]);
|
Raise ESocketError.Create(seConnectFailed,[FFilename]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
end.
|
end.
|
||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.4 2001-01-21 20:45:09 marco
|
Revision 1.5 2001-04-08 11:26:03 peter
|
||||||
|
* update so it can be compiled by both 1.0.x and 1.1
|
||||||
|
|
||||||
|
Revision 1.4 2001/01/21 20:45:09 marco
|
||||||
* Rename fest II FCL version.
|
* Rename fest II FCL version.
|
||||||
|
|
||||||
Revision 1.3 2000/11/17 13:40:53 sg
|
Revision 1.3 2000/11/17 13:40:53 sg
|
||||||
|
@ -32,7 +32,12 @@ uses
|
|||||||
implementation
|
implementation
|
||||||
|
|
||||||
uses
|
uses
|
||||||
Unix;
|
{$ifdef ver1_0}
|
||||||
|
linux
|
||||||
|
{$else}
|
||||||
|
unix
|
||||||
|
{$endif}
|
||||||
|
;
|
||||||
|
|
||||||
{ OS - independent class implementations are in /inc directory. }
|
{ OS - independent class implementations are in /inc directory. }
|
||||||
{$i classes.inc}
|
{$i classes.inc}
|
||||||
@ -50,10 +55,13 @@ finalization
|
|||||||
end.
|
end.
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 2001-01-21 20:45:09 marco
|
Revision 1.4 2001-04-08 11:26:03 peter
|
||||||
|
* update so it can be compiled by both 1.0.x and 1.1
|
||||||
|
|
||||||
|
Revision 1.3 2001/01/21 20:45:09 marco
|
||||||
* Rename fest II FCL version.
|
* Rename fest II FCL version.
|
||||||
|
|
||||||
Revision 1.2 2000/07/13 11:33:01 michael
|
Revision 1.2 2000/07/13 11:33:01 michael
|
||||||
+ removed logs
|
+ removed logs
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -14,7 +14,13 @@
|
|||||||
|
|
||||||
**********************************************************************}
|
**********************************************************************}
|
||||||
|
|
||||||
uses Unix;
|
Uses
|
||||||
|
{$ifdef ver1_0}
|
||||||
|
Linux
|
||||||
|
{$else}
|
||||||
|
Unix
|
||||||
|
{$endif}
|
||||||
|
;
|
||||||
|
|
||||||
Function TProcess.GetRunning : Boolean;
|
Function TProcess.GetRunning : Boolean;
|
||||||
|
|
||||||
@ -42,10 +48,10 @@ begin
|
|||||||
end
|
end
|
||||||
else
|
else
|
||||||
CreatePipeStreams (FParentErrorStream,FChildErrorStream);
|
CreatePipeStreams (FParentErrorStream,FChildErrorStream);
|
||||||
If FCurrentDirectory<>'' then
|
If FCurrentDirectory<>'' then
|
||||||
Chdir(FCurrentDirectory);
|
Chdir(FCurrentDirectory);
|
||||||
FHandle:=fork();
|
FHandle:=fork();
|
||||||
if FHandle=0 then
|
if FHandle=0 then
|
||||||
begin
|
begin
|
||||||
// Child
|
// Child
|
||||||
fdClose(0);
|
fdClose(0);
|
||||||
@ -54,14 +60,14 @@ begin
|
|||||||
dup2(FChildInputStream.Handle,0);
|
dup2(FChildInputStream.Handle,0);
|
||||||
dup2(FCHildOutputStream.Handle,1);
|
dup2(FCHildOutputStream.Handle,1);
|
||||||
dup2(FChildErrorStream.Handle,2);
|
dup2(FChildErrorStream.Handle,2);
|
||||||
execl(FCommandline);
|
execl(FCommandline);
|
||||||
halt(127);
|
halt(127);
|
||||||
end
|
end
|
||||||
else
|
else
|
||||||
begin
|
begin
|
||||||
// Parent
|
// Parent
|
||||||
FPID:=FHandle;
|
FPID:=FHandle;
|
||||||
FThreadHandle:=FHandle;
|
FThreadHandle:=FHandle;
|
||||||
fdclose(FChildOutputStream.Handle);
|
fdclose(FChildOutputStream.Handle);
|
||||||
fdclose(FChildInputStream.Handle);
|
fdclose(FChildInputStream.Handle);
|
||||||
fdclose(FChildErrorStream.Handle);
|
fdclose(FChildErrorStream.Handle);
|
||||||
@ -106,10 +112,13 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 2001-01-21 20:45:09 marco
|
Revision 1.4 2001-04-08 11:26:03 peter
|
||||||
|
* update so it can be compiled by both 1.0.x and 1.1
|
||||||
|
|
||||||
|
Revision 1.3 2001/01/21 20:45:09 marco
|
||||||
* Rename fest II FCL version.
|
* Rename fest II FCL version.
|
||||||
|
|
||||||
Revision 1.2 2000/07/13 11:33:01 michael
|
Revision 1.2 2000/07/13 11:33:01 michael
|
||||||
+ removed logs
|
+ removed logs
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -217,7 +217,7 @@ var
|
|||||||
P: Integer;
|
P: Integer;
|
||||||
I: TThreadPriority;
|
I: TThreadPriority;
|
||||||
begin
|
begin
|
||||||
P := Unix.GetPriority(Prio_Process,FHandle);
|
P := {$ifdef ver1_0}Linux{$else}Unix{$endif}.GetPriority(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
|
||||||
@ -227,7 +227,7 @@ end;
|
|||||||
|
|
||||||
procedure TThread.SetPriority(Value: TThreadPriority);
|
procedure TThread.SetPriority(Value: TThreadPriority);
|
||||||
begin
|
begin
|
||||||
Unix.SetPriority(Prio_Process,FHandle, Priorities[Value]);
|
{$ifdef ver1_0}Linux{$else}Unix{$endif}.SetPriority(Prio_Process,FHandle, Priorities[Value]);
|
||||||
end;
|
end;
|
||||||
|
|
||||||
|
|
||||||
@ -283,10 +283,13 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 2001-01-21 20:45:09 marco
|
Revision 1.4 2001-04-08 11:26:03 peter
|
||||||
|
* update so it can be compiled by both 1.0.x and 1.1
|
||||||
|
|
||||||
|
Revision 1.3 2001/01/21 20:45:09 marco
|
||||||
* Rename fest II FCL version.
|
* Rename fest II FCL version.
|
||||||
|
|
||||||
Revision 1.2 2000/07/13 11:33:01 michael
|
Revision 1.2 2000/07/13 11:33:01 michael
|
||||||
+ removed logs
|
+ removed logs
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,13 @@
|
|||||||
|
|
||||||
**********************************************************************}
|
**********************************************************************}
|
||||||
|
|
||||||
uses Unix,classes;
|
uses
|
||||||
|
{$ifdef ver1_0}
|
||||||
|
Linux,
|
||||||
|
{$else}
|
||||||
|
Unix,
|
||||||
|
{$endif}
|
||||||
|
classes;
|
||||||
|
|
||||||
const
|
const
|
||||||
MaxHandle = SizeOf(TFDSet) * 8 - 1;
|
MaxHandle = SizeOf(TFDSet) * 8 - 1;
|
||||||
@ -25,7 +31,10 @@ Type
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 2001-01-21 20:45:09 marco
|
Revision 1.4 2001-04-08 11:26:03 peter
|
||||||
|
* update so it can be compiled by both 1.0.x and 1.1
|
||||||
|
|
||||||
|
Revision 1.3 2001/01/21 20:45:09 marco
|
||||||
* Rename fest II FCL version.
|
* Rename fest II FCL version.
|
||||||
|
|
||||||
Revision 1.2 2000/10/26 22:30:21 peter
|
Revision 1.2 2000/10/26 22:30:21 peter
|
||||||
|
@ -13,7 +13,13 @@
|
|||||||
**********************************************************************}
|
**********************************************************************}
|
||||||
|
|
||||||
|
|
||||||
Uses Unix;
|
Uses
|
||||||
|
{$ifdef ver1_0}
|
||||||
|
Linux
|
||||||
|
{$else}
|
||||||
|
Unix
|
||||||
|
{$endif}
|
||||||
|
;
|
||||||
|
|
||||||
{ Declared EXPLICITLY with Ansistring, so NO mistaking is possible }
|
{ Declared EXPLICITLY with Ansistring, so NO mistaking is possible }
|
||||||
|
|
||||||
@ -23,7 +29,7 @@ Var P : Pchar;
|
|||||||
|
|
||||||
begin
|
begin
|
||||||
// Linux version returns pchar.
|
// Linux version returns pchar.
|
||||||
p:=Unix.getenv(EnvVar);
|
p:={$ifdef ver1_0}Linux{$else}Unix{$endif}.getenv(EnvVar);
|
||||||
if P<>nil then
|
if P<>nil then
|
||||||
getenv:=strpas(p)
|
getenv:=strpas(p)
|
||||||
else
|
else
|
||||||
@ -32,7 +38,10 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 2001-01-21 20:45:09 marco
|
Revision 1.4 2001-04-08 11:26:03 peter
|
||||||
|
* update so it can be compiled by both 1.0.x and 1.1
|
||||||
|
|
||||||
|
Revision 1.3 2001/01/21 20:45:09 marco
|
||||||
* Rename fest II FCL version.
|
* Rename fest II FCL version.
|
||||||
|
|
||||||
Revision 1.2 2000/10/26 22:30:21 peter
|
Revision 1.2 2000/10/26 22:30:21 peter
|
||||||
|
@ -14,7 +14,13 @@
|
|||||||
|
|
||||||
**********************************************************************}
|
**********************************************************************}
|
||||||
|
|
||||||
uses Unix;
|
Uses
|
||||||
|
{$ifdef ver1_0}
|
||||||
|
Linux
|
||||||
|
{$else}
|
||||||
|
Unix
|
||||||
|
{$endif}
|
||||||
|
;
|
||||||
|
|
||||||
Function CreatePipeHandles (Var Inhandle,OutHandle : Longint) : Boolean;
|
Function CreatePipeHandles (Var Inhandle,OutHandle : Longint) : Boolean;
|
||||||
|
|
||||||
@ -24,7 +30,10 @@ end;
|
|||||||
|
|
||||||
{
|
{
|
||||||
$Log$
|
$Log$
|
||||||
Revision 1.3 2001-01-21 20:45:09 marco
|
Revision 1.4 2001-04-08 11:26:03 peter
|
||||||
|
* update so it can be compiled by both 1.0.x and 1.1
|
||||||
|
|
||||||
|
Revision 1.3 2001/01/21 20:45:09 marco
|
||||||
* Rename fest II FCL version.
|
* Rename fest II FCL version.
|
||||||
|
|
||||||
Revision 1.2 2000/10/26 22:30:21 peter
|
Revision 1.2 2000/10/26 22:30:21 peter
|
||||||
|
Loading…
Reference in New Issue
Block a user