2
$Id: process.inc,v 1.5 2002/09/07 15:15:24 peter Exp $
3
This file is part of the Free Pascal run time library.
4
Copyright (c) 1999-2000 by Michael Van Canneyt
6
Linux specific part of TProcess.
8
See the file COPYING.FPC, included in this distribution,
9
for details about the copyright.
11
This program is distributed in the hope that it will be useful,
12
but WITHOUT ANY WARRANTY; without even the implied warranty of
13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
15
**********************************************************************}
25
Function TProcess.GetRunning : Boolean;
29
FRunning:=GetExitStatus=-1;
33
Procedure TProcess.Execute;
37
CreatePipeStreams (FChildInputSTream,FParentOutPutStream);
38
CreatePipeStreams (FParentInputStream,FChildOutPutStream);
39
If poUsePipes in FCreateOptions then
41
if poStdErrToOutPut in FCreateOptions then
42
CreatePipeStreams (FParentErrorStream,FChildErrorStream)
45
FChildErrorStream:=FChildOutPutStream;
46
FParentErrorStream:=FParentInputStream;
50
CreatePipeStreams (FParentErrorStream,FChildErrorStream);
51
If FCurrentDirectory<>'' then
52
Chdir(FCurrentDirectory);
60
dup2(FChildInputStream.Handle,0);
61
dup2(FCHildOutputStream.Handle,1);
62
dup2(FChildErrorStream.Handle,2);
70
FThreadHandle:=FHandle;
71
fdclose(FChildOutputStream.Handle);
72
fdclose(FChildInputStream.Handle);
73
fdclose(FChildErrorStream.Handle);
75
if (poWaitOnExit in FCreateOptions) and
76
not (poRunSuspended in FCreateOptions) then
81
Function TProcess.WaitOnExit : Dword;
84
waitpid(FPID, nil, 0);
86
Result:=WaitForSingleObject (FprocessInformation.hProcess,Infinite);
87
If Result<>Wait_Failed then
93
Function TProcess.Suspend : Longint;
96
Result:=Kill(Handle,SIGSTOP);
99
Function TProcess.Resume : LongInt;
102
Result:=Kill(FHandle,SIGCONT);
105
Function TProcess.Terminate(AExitCode : Integer) : Boolean;
109
If ExitStatus=-1 then
110
Result:=Kill(FHandle,SIGTERM)=0;
114
$Log: process.inc,v $
115
Revision 1.5 2002/09/07 15:15:24 peter
116
* old logs removed and tabs fixed