mirror of
https://gitlab.com/freepascal.org/fpc/source.git
synced 2025-08-24 12:29:24 +02:00
* fixes to work again
This commit is contained in:
parent
df4eb26ed0
commit
ec95ce1f48
@ -71,4 +71,5 @@ ex67.pp contains an example of the FSplit function.
|
||||
ex68.pp contains an example of the Octal function.
|
||||
ex69.pp contains an example of the FNMatch function.
|
||||
ex70.pp contains an example of the StringToPPchar function.
|
||||
ex71.pp contains an example of the clone function.
|
||||
serial.pp contains an example of serial port programming in FPC.
|
||||
|
71
docs/linuxex/ex71.pp
Normal file
71
docs/linuxex/ex71.pp
Normal file
@ -0,0 +1,71 @@
|
||||
program TestC{lone};
|
||||
|
||||
uses
|
||||
Linux, Errors, crt;
|
||||
|
||||
const
|
||||
Ready : Boolean = false;
|
||||
aChar : Char = 'a';
|
||||
|
||||
function CloneProc( Arg: Pointer ): LongInt; Cdecl;
|
||||
begin
|
||||
WriteLn('Hello from the clone ',PChar(Arg));
|
||||
repeat
|
||||
Write(aChar);
|
||||
Select(0,0,0,0,600);
|
||||
until Ready;
|
||||
WriteLn( 'Clone finished.');
|
||||
CloneProc := 1;
|
||||
end;
|
||||
|
||||
var
|
||||
PID : LongInt;
|
||||
|
||||
procedure MainProc;
|
||||
begin
|
||||
WriteLn('cloned process PID: ', PID );
|
||||
WriteLn('Press <ESC> to kill ... ' );
|
||||
repeat
|
||||
Write('.');
|
||||
Select(0,0,0,0,300);
|
||||
if KeyPressed then
|
||||
case ReadKey of
|
||||
#27: Ready := true;
|
||||
'a': aChar := 'A';
|
||||
'A': aChar := 'a';
|
||||
'b': aChar := 'b';
|
||||
'B': aChar := 'B';
|
||||
end;
|
||||
until Ready;
|
||||
WriteLn('Ready.');
|
||||
end;
|
||||
|
||||
const
|
||||
StackSze = 16384;
|
||||
theFlags = CLONE_VM+CLONE_FS+CLONE_FILES+CLONE_SIGHAND;
|
||||
aMsg : PChar = 'Oops !';
|
||||
|
||||
var
|
||||
theStack : Pointer;
|
||||
ExitStat : LongInt;
|
||||
|
||||
begin
|
||||
GetMem(theStack,StackSze);
|
||||
PID := Clone(@CloneProc,
|
||||
Pointer( LongInt(theStack)+StackSze),
|
||||
theFlags,
|
||||
aMsg);
|
||||
if PID < 0 then
|
||||
WriteLn('Error : ', LinuxError, ' when cloning.')
|
||||
else
|
||||
begin
|
||||
MainProc;
|
||||
case WaitPID(0,@ExitStat,Wait_Untraced or wait_clone) of
|
||||
-1: WriteLn('error:',LinuxError,'; ',StrError(LinuxError));
|
||||
0: WriteLn('error:',LinuxError,'; ',StrError(LinuxError));
|
||||
else
|
||||
WriteLn('Clone exited with: ',ExitStat shr 8);
|
||||
end;
|
||||
end;
|
||||
FreeMem( theStack, StackSze );
|
||||
end.
|
@ -32,14 +32,13 @@
|
||||
\usepackage{html}
|
||||
\usepackage{htmllist}
|
||||
\latex{\usepackage{fpc}}
|
||||
\html{\input{fpc-html.tex}}
|
||||
\else
|
||||
\usepackage{fpc}
|
||||
\fi
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Uncomment the fpc or fpcbook version, depending on the output format
|
||||
% you want.
|
||||
%\usepackage{fpc}
|
||||
\usepackage{fpc}
|
||||
%\usepackage{fpcbook}
|
||||
\fi
|
||||
\latex{%
|
||||
\ifpdf
|
||||
\pdfinfo{/Author(Michael Van Canneyt)
|
||||
|
@ -31,12 +31,12 @@
|
||||
\usepackage{html}
|
||||
\usepackage{htmllist}
|
||||
\latex{\usepackage{fpc}}
|
||||
\html{\input{fpc-html.tex}}
|
||||
\else
|
||||
b%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Uncomment the fpc or fpcbook version, depending on the output format
|
||||
% you want.
|
||||
\usepackage{fpc}
|
||||
\usepackage{fpcbook}
|
||||
% \usepackage{fpcbook}
|
||||
\fi
|
||||
\latex{%
|
||||
\ifpdf
|
||||
|
@ -27,27 +27,19 @@
|
||||
%
|
||||
% Preamble
|
||||
%
|
||||
\usepackage{multicol}
|
||||
\ifx\pdfoutput\undefined
|
||||
\usepackage{html}
|
||||
\usepackage{htmllist}
|
||||
\latex{\usepackage{fpc}}
|
||||
\html{\input{fpc-html.tex}}
|
||||
\else
|
||||
\usepackage{fpc}
|
||||
\fi
|
||||
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
|
||||
% Uncomment the fpc or fpcbook version, depending on the output format
|
||||
% you want.
|
||||
\usepackage{fpc}
|
||||
%\usepackage{fpcbook}
|
||||
\latex{\usepackage{multicol}}
|
||||
\fi
|
||||
\latex{%
|
||||
\ifpdf
|
||||
\pdfcompresslevel=9
|
||||
\pdfpagewidth=210mm
|
||||
\pdfpageheight=297mm
|
||||
%
|
||||
\html{\input{fpc-html.tex}}
|
||||
%
|
||||
\ifpdf
|
||||
\pdfinfo{/Author(Michael Van Canneyt)
|
||||
/Title(Standard units Reference Guide)
|
||||
@ -55,6 +47,7 @@
|
||||
/Keywords(Free Pascal, Units, RTL)
|
||||
}
|
||||
\fi
|
||||
}
|
||||
%
|
||||
% Settings
|
||||
%
|
||||
|
@ -31,6 +31,7 @@
|
||||
\usepackage{html}
|
||||
\usepackage{htmllist}
|
||||
\latex{\usepackage{fpc}}
|
||||
\html{\input{fpc-html.tex}}
|
||||
\else
|
||||
\usepackage{fpc}
|
||||
% \usepackage{fpcbook}
|
||||
|
Loading…
Reference in New Issue
Block a user