mirror of
				https://gitlab.com/freepascal.org/fpc/source.git
				synced 2025-10-31 10:11:27 +01: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. | ex68.pp contains an example of the Octal function. | ||||||
| ex69.pp contains an example of the FNMatch function. | ex69.pp contains an example of the FNMatch function. | ||||||
| ex70.pp contains an example of the StringToPPchar 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. | 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{html} | ||||||
|   \usepackage{htmllist} |   \usepackage{htmllist} | ||||||
|   \latex{\usepackage{fpc}} |   \latex{\usepackage{fpc}} | ||||||
|  |   \html{\input{fpc-html.tex}} | ||||||
| \else | \else | ||||||
|  |   % Uncomment the fpc or fpcbook version, depending on the output format | ||||||
|  |   % you want. | ||||||
|   \usepackage{fpc} |   \usepackage{fpc} | ||||||
|  |   %\usepackage{fpcbook} | ||||||
| \fi | \fi | ||||||
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |  | ||||||
| % Uncomment the fpc or fpcbook version, depending on the output format  |  | ||||||
| % you want. |  | ||||||
| %\usepackage{fpc} |  | ||||||
| %\usepackage{fpcbook} |  | ||||||
| \latex{% | \latex{% | ||||||
|   \ifpdf |   \ifpdf | ||||||
|   \pdfinfo{/Author(Michael Van Canneyt) |   \pdfinfo{/Author(Michael Van Canneyt) | ||||||
| @ -47,7 +46,7 @@ | |||||||
|            /Subject(Free Pascal Programmers' guide) |            /Subject(Free Pascal Programmers' guide) | ||||||
|            /Keywords(Free Pascal) |            /Keywords(Free Pascal) | ||||||
|            } |            } | ||||||
| \fi |   \fi | ||||||
| } | } | ||||||
| % | % | ||||||
| % Settings | % Settings | ||||||
|  | |||||||
| @ -31,12 +31,12 @@ | |||||||
|   \usepackage{html} |   \usepackage{html} | ||||||
|   \usepackage{htmllist} |   \usepackage{htmllist} | ||||||
|   \latex{\usepackage{fpc}} |   \latex{\usepackage{fpc}} | ||||||
|  |   \html{\input{fpc-html.tex}} | ||||||
| \else | \else | ||||||
| b%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |  | ||||||
| % Uncomment the fpc or fpcbook version, depending on the output format | % Uncomment the fpc or fpcbook version, depending on the output format | ||||||
| % you want. | % you want. | ||||||
|   \usepackage{fpc} |   \usepackage{fpc} | ||||||
|   \usepackage{fpcbook} | %  \usepackage{fpcbook} | ||||||
| \fi | \fi | ||||||
| \latex{% | \latex{% | ||||||
|   \ifpdf |   \ifpdf | ||||||
|  | |||||||
| @ -27,34 +27,27 @@ | |||||||
| % | % | ||||||
| % Preamble | % Preamble | ||||||
| % | % | ||||||
|  | \usepackage{multicol} | ||||||
| \ifx\pdfoutput\undefined | \ifx\pdfoutput\undefined | ||||||
|   \usepackage{html} |   \usepackage{html} | ||||||
|   \usepackage{htmllist} |   \usepackage{htmllist} | ||||||
|   \latex{\usepackage{fpc}} |   \latex{\usepackage{fpc}} | ||||||
|  |   \html{\input{fpc-html.tex}} | ||||||
| \else | \else | ||||||
|   \usepackage{fpc} |  | ||||||
| \fi |  | ||||||
| %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% |  | ||||||
| % Uncomment the fpc or fpcbook version, depending on the output format | % Uncomment the fpc or fpcbook version, depending on the output format | ||||||
| % you want. | % you want. | ||||||
| \usepackage{fpc} |   \usepackage{fpc} | ||||||
| %\usepackage{fpcbook} |   %\usepackage{fpcbook} | ||||||
| \latex{\usepackage{multicol}} | \fi | ||||||
| \latex{% | \latex{% | ||||||
|   \ifpdf |   \ifpdf | ||||||
|   \pdfcompresslevel=9 |     \pdfinfo{/Author(Michael Van Canneyt) | ||||||
|   \pdfpagewidth=210mm |              /Title(Standard units Reference Guide) | ||||||
|   \pdfpageheight=297mm |              /Subject(Free Pascal Standard units reference guide) | ||||||
| % |              /Keywords(Free Pascal, Units, RTL) | ||||||
| \html{\input{fpc-html.tex}} |              } | ||||||
| % |   \fi | ||||||
| \ifpdf | } | ||||||
|   \pdfinfo{/Author(Michael Van Canneyt) |  | ||||||
|            /Title(Standard units Reference Guide) |  | ||||||
|            /Subject(Free Pascal Standard units reference guide) |  | ||||||
|            /Keywords(Free Pascal, Units, RTL) |  | ||||||
|            } |  | ||||||
| \fi |  | ||||||
| % | % | ||||||
| % Settings | % Settings | ||||||
| % | % | ||||||
|  | |||||||
| @ -31,6 +31,7 @@ | |||||||
|   \usepackage{html} |   \usepackage{html} | ||||||
|   \usepackage{htmllist} |   \usepackage{htmllist} | ||||||
|   \latex{\usepackage{fpc}} |   \latex{\usepackage{fpc}} | ||||||
|  |   \html{\input{fpc-html.tex}} | ||||||
| \else | \else | ||||||
|   \usepackage{fpc} |   \usepackage{fpc} | ||||||
| %  \usepackage{fpcbook} | %  \usepackage{fpcbook} | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user
	 peter
						peter