* fixes to work again

This commit is contained in:
peter 2000-09-25 21:07:14 +00:00
parent df4eb26ed0
commit ec95ce1f48
6 changed files with 111 additions and 46 deletions

View File

@ -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
View 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.

View File

@ -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)

View File

@ -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

View File

@ -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
%

View File

@ -31,6 +31,7 @@
\usepackage{html}
\usepackage{htmllist}
\latex{\usepackage{fpc}}
\html{\input{fpc-html.tex}}
\else
\usepackage{fpc}
% \usepackage{fpcbook}