Преглед изворни кода

fixed trap initialization
- signal numbers differ between linux/darwin/solaris
- Unix.HandleSignal() may no handle SIGUSER1 and SIGUSR2!

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7561 8c9fc860-2736-0410-a75d-ab315db34111

eth.guenter пре 7 година
родитељ
комит
b59c3b3dca

+ 32 - 32
source/Generic.Darwin.I386.Unix.Mod

@@ -85,38 +85,38 @@ CONST
 	SCHED_RR = 2;
 
 
-	SIGHUP		= 1;	(* hangup *)
-	SIGINT		= 2;	(* interrupt *)
-	SIGQUIT		= 3;	(* quit *)
-	SIGILL			= 4;	(* illegal instruction (not reset when caught) *)
-	SIGTRAP		= 5;	(* trace trap (not reset when caught) *)
-	SIGABRT		= 6;	(* abort() *)
-	SIGIOT		= SIGABRT;	(* compatibility *)
-	SIGEMT		= 7;	(* EMT instruction *)
-	SIGFPE		= 8;	(* floating point exception *)
-	SIGKILL		= 9;	(* kill (cannot be caught or ignored) *)
-	SIGBUS		= 10;	(* bus error *)
-	SIGSEGV		= 11;	(* segmentation violation *)
-	SIGSYS		= 12;	(* bad argument to system call *)
-	SIGPIPE		= 13;	(* write on a pipe with no one to read it *)
-	SIGALRM		= 14;	(* alarm clock *)
-	SIGTERM		= 15;	(* software termination signal from kill *)
-	SIGURG		= 16;	(* urgent condition on IO channel *)
-	SIGSTOP		= 17;	(* sendable stop signal not from tty *)
-	SIGTSTP		= 18;	(* stop signal from tty *)
-	SIGCONT		= 19;	(* continue a stopped process *)
-	SIGCHLD		= 20;	(* to parent on child stop or exit *)
-	SIGTTIN		= 21;	(* to readers pgrp upon background tty read *)
-	SIGTTOU		= 22;	(* like TTIN for output if (tp->t_local&LTOSTOP) *)
-	SIGIO			= 23;	(* input/output possible signal *)
-	SIGXCPU		= 24;	(* exceeded CPU time limit *)
-	SIGXFSZ		= 25;	(* exceeded file size limit *)
-	SIGVTALRM	= 26;	(* virtual time alarm *)
-	SIGPROF		= 27;	(* profiling time alarm *)
-	SIGWINCH	= 28;	(* window size changes *)
-	SIGINFO		= 29;	(* information request *)
-	SIGUSR1		= 30;	(* user d signal 1 *)
-	SIGUSR2		= 31;	(* user d signal 2 *)
+	SIGHUP*		= 1;	(* hangup *)
+	SIGINT*		= 2;	(* interrupt *)
+	SIGQUIT*	= 3;	(* quit *)
+	SIGILL	*		= 4;	(* illegal instruction (not reset when caught) *)
+	SIGTRAP*	= 5;	(* trace trap (not reset when caught) *)
+	SIGABRT*	= 6;	(* abort() *)
+	SIGIOT*		= SIGABRT;	(* compatibility *)
+	SIGEMT*		= 7;	(* EMT instruction *)
+	SIGFPE*		= 8;	(* floating point exception *)
+	SIGKILL*		= 9;	(* kill (cannot be caught or ignored) *)
+	SIGBUS*		= 10;	(* bus error *)
+	SIGSEGV	*	= 11;	(* segmentation violation *)
+	SIGSYS*		= 12;	(* bad argument to system call *)
+	SIGPIPE*	= 13;	(* write on a pipe with no one to read it *)
+	SIGALRM	*	= 14;	(* alarm clock *)
+	SIGTERM	*	= 15;	(* software termination signal from kill *)
+	SIGURG*		= 16;	(* urgent condition on IO channel *)
+	SIGSTOP*	= 17;	(* sendable stop signal not from tty *)
+	SIGTSTP*	= 18;	(* stop signal from tty *)
+	SIGCONT*	= 19;	(* continue a stopped process *)
+	SIGCHLD*	= 20;	(* to parent on child stop or exit *)
+	SIGTTIN*		= 21;	(* to readers pgrp upon background tty read *)
+	SIGTTOU*	= 22;	(* like TTIN for output if (tp->t_local&LTOSTOP) *)
+	SIGIO*		= 23;	(* input/output possible signal *)
+	SIGXCPU*	= 24;	(* exceeded CPU time limit *)
+	SIGXFSZ*	= 25;	(* exceeded file size limit *)
+	SIGVTALRM*= 26;	(* virtual time alarm *)
+	SIGPROF*	= 27;	(* profiling time alarm *)
+	SIGWINCH*	= 28;	(* window size changes *)
+	SIGINFO*	= 29;	(* information request *)
+	SIGUSR1*	= 30;	(* user d signal 1 *)
+	SIGUSR2*	= 31;	(* user d signal 2 *)
 
 	SIG_BLOCK		= 1;
 	SIG_UNBLOCK	= 2;

+ 34 - 34
source/Generic.Linux.I386.Unix.Mod

@@ -85,40 +85,40 @@ CONST
 	T_SIGRESUME = SIGUSR1;
 	T_SIGSUSPEND = SIGUSR2;
 
-	SIGHUP = 1;
-	SIGINT = 2;
-	SIGQUIT=3;
-	SIGILL = 4;
-	SIGTRAP = 5;
-	SIGABRT = 6;
-	SIGIOT = 6;
-	SIGBUS = 7;
-	SIGFPE = 8;
-	SIGKILL = 9;
-	SIGUSR1 = 10;
-	SIGSEGV = 11;
-	SIGUSR2 = 12;
-	SIGPIPE = 13;
-	SIGALRM = 14;
-	SIGTERM = 15;
-	SIGSTKFLT = 16;
-	SIGCHLD = 17;
-	SIGCONT = 18;
-	SIGSTOP = 19;
-	SIGTSTP = 20;
-	SIGTTIN = 21;
-	SIGTTOU = 22;
-	SIGURG = 23;
-	SIGXCPU = 24;
-	SIGXFSZ = 25;
-	SIGVTALRM = 26;
-	SIGPROF = 27;
-	SIGWINCH=28;
-	SIGIO=29;
-	SIGPOLL = SIGIO;
-	SIGPWR = 30;
-	SIGSYS = 31;
-	SIGUNUSED =31;
+	SIGHUP*		= 1;
+	SIGINT*		= 2;
+	SIGQUIT*	=3;
+	SIGILL*		= 4;
+	SIGTRAP*	= 5;
+	SIGABRT*	= 6;
+	SIGIOT*		= 6;
+	SIGBUS*		= 7;
+	SIGFPE*		= 8;
+	SIGKILL*		= 9;
+	SIGUSR1*	= 10;
+	SIGSEGV*	= 11;
+	SIGUSR2*	= 12;
+	SIGPIPE*	= 13;
+	SIGALRM*	= 14;
+	SIGTERM*	= 15;
+	SIGSTKFLT*	= 16;
+	SIGCHLD*	= 17;
+	SIGCONT*	= 18;
+	SIGSTOP*	= 19;
+	SIGTSTP*	= 20;
+	SIGTTIN*		= 21;
+	SIGTTOU*	= 22;
+	SIGURG*		= 23;
+	SIGXCPU*	= 24;
+	SIGXFSZ*	= 25;
+	SIGVTALRM*	= 26;
+	SIGPROF*	= 27;
+	SIGWINCH*	=28;
+	SIGIO*		=29;
+	SIGPOLL*	= SIGIO;
+	SIGPWR*	= 30;
+	SIGSYS*		= 31;
+	SIGUNUSED = 31;
 
 	SIG_BLOCK = 0;
 	SIG_UNBLOCK=1;

+ 43 - 43
source/Generic.Solaris.I386.Unix.Mod

@@ -78,49 +78,49 @@ CONST
 	ENOLCK* = 37;   (* No record locks available. *)
 	
 	(* Unix signals *)
-	SIGHUP		=  1;		(* hangup *)
-	SIGINT		=  2;		(* interrupt (rubout) *)
-	SIGQUIT		=  3;		(* quit (ASCII FS) *)
-	SIGILL			=  4;		(* illegal instruction (not reset when caught) *)
-	SIGTRAP		=  5;		(* trace trap (not reset when caught) *)
-	SIGIOT		=  6;		(* IOT instruction *)
-	SIGABRT		=  6;		(* used by abort, replace SIGIOT in the future *)
-	SIGEMT		=  7;		(* EMT instruction *)
-	SIGFPE		=  8;		(* floating point exception *)
-	SIGKILL		=  9;		(* kill (cannot be caught or ignored) *)
-	SIGBUS		= 10;		(* bus error *)
-	SIGSEGV		= 11;		(* segmentation violation *)
-	SIGSYS		= 12;		(* bad argument to system call *)
-	SIGPIPE		= 13;		(* write on a pipe with no one to read it *)
-	SIGALRM		= 14;		(* alarm clock *)
-	SIGTERM		= 15;		(* software termination signal from kill *)
-	SIGUSR1		= 16;		(* user defined signal 1 *)
-	SIGUSR2		= 17;		(* user defined signal 2 *)
-	SIGCLD		= 18;		(* child status change *)
-	SIGCHLD		= 18;		(* child status change alias (POSIX) *)
-	SIGPWR		= 19;		(* power-fail restart *)
-	SIGWINCH	= 20;    	(* window size change *)
-	SIGURG		= 21;		(* urgent socket condition *)
-	SIGPOLL		= 22;		(* pollable event occured *)
-	SIGIO			= SIGPOLL;	(* socket I/O possible (SIGPOLL alias) *)
-	SIGSTOP		= 23;		(* stop (cannot be caught or ignored) *)
-	SIGTSTP		= 24;		(* user stop requested from tty *)
-	SIGCONT		= 25;		(* stopped process has been continued *)
-	SIGTTIN		= 26;		(* background tty read attempted *)
-	SIGTTOU		= 27;		(* background tty write attempted *)
-	SIGVTALRM	= 28;		(* virtual timer expired *)
-	SIGPROF		= 29;		(* profiling timer expired *)
-	SIGXCPU		= 30;		(* exceeded cpu limit *)
-	SIGXFSZ		= 31;		(* exceeded file size limit *)
-	SIGWAITING	= 32;  		(* reserved signal no longer used by threading code *)
-	SIGAIOCANCEL	= 33;	(* reserved signal for aio cancellation *)
-	SIGFREEZE	= 34;   	(* special signal used by CPR *)
-	SIGTHAW	= 35;		(* special signal used by CPR *)
-	SIGCANCEL	= 36;  		(* reserved signal for thread cancellation *)
-	SIGLOST		= 37;		(* resource lost (eg, record-lock lost) *)
-	SIGXRES		= 38;		(* resource control exceeded *)
-	SIGJVM1		= 39;		(* reserved signal for Java Virtual Machine *)
-	SIGJVM2		= 40;		(* reserved signal for Java Virtual Machine *)
+	SIGHUP*		=  1;		(* hangup *)
+	SIGINT*		=  2;		(* interrupt (rubout) *)
+	SIGQUIT*	=  3;		(* quit (ASCII FS) *)
+	SIGILL*		=  4;		(* illegal instruction (not reset when caught) *)
+	SIGTRAP*	=  5;		(* trace trap (not reset when caught) *)
+	SIGIOT*		=  6;		(* IOT instruction *)
+	SIGABRT*	=  6;		(* used by abort, replace SIGIOT in the future *)
+	SIGEMT*		=  7;		(* EMT instruction *)
+	SIGFPE*		=  8;		(* floating point exception *)
+	SIGKILL*		=  9;		(* kill (cannot be caught or ignored) *)
+	SIGBUS*		= 10;		(* bus error *)
+	SIGSEGV*	= 11;		(* segmentation violation *)
+	SIGSYS*		= 12;		(* bad argument to system call *)
+	SIGPIPE*	= 13;		(* write on a pipe with no one to read it *)
+	SIGALRM*	= 14;		(* alarm clock *)
+	SIGTERM	*	= 15;		(* software termination signal from kill *)
+	SIGUSR1*	= 16;		(* user defined signal 1 *)
+	SIGUSR2*	= 17;		(* user defined signal 2 *)
+	SIGCLD*		= 18;		(* child status change *)
+	SIGCHLD*	= 18;		(* child status change alias (POSIX) *)
+	SIGPWR*	= 19;		(* power-fail restart *)
+	SIGWINCH*	= 20;    	(* window size change *)
+	SIGURG*		= 21;		(* urgent socket condition *)
+	SIGPOLL*	= 22;		(* pollable event occured *)
+	SIGIO*		= SIGPOLL;	(* socket I/O possible (SIGPOLL alias) *)
+	SIGSTOP*	= 23;		(* stop (cannot be caught or ignored) *)
+	SIGTSTP*	= 24;		(* user stop requested from tty *)
+	SIGCONT*	= 25;		(* stopped process has been continued *)
+	SIGTTIN*		= 26;		(* background tty read attempted *)
+	SIGTTOU*	= 27;		(* background tty write attempted *)
+	SIGVTALRM*= 28;		(* virtual timer expired *)
+	SIGPROF*	= 29;		(* profiling timer expired *)
+	SIGXCPU*	= 30;		(* exceeded cpu limit *)
+	SIGXFSZ*	= 31;		(* exceeded file size limit *)
+	SIGWAITING*		= 32;  		(* reserved signal no longer used by threading code *)
+	SIGAIOCANCEL*	= 33;	(* reserved signal for aio cancellation *)
+	SIGFREEZE*	= 34;   	(* special signal used by CPR *)
+	SIGTHAW*		= 35;		(* special signal used by CPR *)
+	SIGCANCEL*	= 36;  		(* reserved signal for thread cancellation *)
+	SIGLOST*		= 37;		(* resource lost (eg, record-lock lost) *)
+	SIGXRES*		= 38;		(* resource control exceeded *)
+	SIGJVM1*		= 39;		(* reserved signal for Java Virtual Machine *)
+	SIGJVM2*		= 40;		(* reserved signal for Java Virtual Machine *)
 	
 	
 	SIG_BLOCK = 1;

+ 10 - 10
source/Generic.Unix.Traps.Mod

@@ -153,11 +153,11 @@ VAR
 					ELSE  w.String( "  (unknown exception)" )
 					END
 				END;
-		|  8:	w.String( "8 (Arithmetic exception)" );
-		|10: 	w.String( "10 (Bus Error)" )
-		|11:	w.String( "11 (Segmentation violation)" )
-		|13:	w.String( "13 (Broken pipe)" )
-		|14:	w.String( "14 (Alarm signal)" )
+		| Unix.SIGBUS:  w.Int( sig, 0 );  w.String( " (Bus Error)" )
+		| Unix.SIGFPE:  w.Int( sig, 0 );  w.String( " (Arithmetic exception)" );
+		| 11:	w.String( "11 (Segmentation violation)" )
+		| 13:	w.String( "13 (Broken pipe)" )
+		| 14:	w.String( "14 (Alarm signal)" )
 		ELSE
 			w.String( "(Signal " );  w.Int( sig, 0 );  w.Char( ')' );
 		END;
@@ -258,10 +258,10 @@ BEGIN
 	trapMutex := Unix.NewRecursiveMtx( );
 	trace := FALSE;  
 	Unix.InstallTrap( Trap );
-	Unix.HandleSignal( 4 ); (* SIGILL: illegal instruction *)
-	Unix.HandleSignal( 5 ); (* SIGTRAP: exception *)
-	Unix.HandleSignal( 7 ); (* SIGBUS: bus error *)
-	Unix.HandleSignal( 8 ); (* SIGFPE: erroneous arithmetics *)
-	Unix.HandleSignal( 11 ); (* SIGSEGV: segmentation fault *)
+	Unix.HandleSignal( Unix.SIGILL ); (* illegal instruction *)
+	Unix.HandleSignal( Unix.SIGTRAP ); (* exception *)
+	Unix.HandleSignal( Unix.SIGBUS ); (* bus error *)
+	Unix.HandleSignal( Unix.SIGFPE ); (* erroneous arithmetics *)
+	Unix.HandleSignal( Unix.SIGSEGV ); (* segmentation fault *)
 	unix := StdIO.env
 END Traps.

+ 13 - 3
source/Unix.BootConsole.Mod

@@ -180,9 +180,19 @@ VAR
 	PROCEDURE InitSignalHandling;
 	VAR i: LONGINT;
 	BEGIN
-		FOR i := 1 TO 15 DO
-			IF i # 9 THEN Unix.HandleSignal( i ) END;
-		END;
+		Unix.HandleSignal( Unix.SIGHUP );
+		Unix.HandleSignal( Unix.SIGINT );
+		Unix.HandleSignal( Unix.SIGQUIT );
+		Unix.HandleSignal( Unix.SIGILL );
+		Unix.HandleSignal( Unix.SIGTRAP );
+		
+		Unix.HandleSignal( Unix.SIGABRT );
+		Unix.HandleSignal( Unix.SIGBUS );
+		Unix.HandleSignal( Unix.SIGFPE );
+		Unix.HandleSignal( Unix.SIGBUS );
+		Unix.HandleSignal( Unix.SIGPIPE );
+		Unix.HandleSignal( Unix.SIGALRM );
+		Unix.HandleSignal( Unix.SIGTERM );
 	END InitSignalHandling;
 	
 BEGIN