Browse Source

sigaltstack corrected

Alexander Shiryaev 12 years ago
parent
commit
9fcf0c8450

BIN
BlackBox/Linux/Lin/Mod/Kernel.odc


+ 7 - 6
BlackBox/Linux/Lin/Mod/Kernel.txt

@@ -1873,12 +1873,12 @@ MODULE Kernel;
 	END TrapHandler;
 
 	PROCEDURE InstallSignals*;
-		(* CONST
-			sigStackSize = Libc.SIGSTKSZ; *)
+		CONST
+			sigStackSize = Libc.SIGSTKSZ;
 		VAR sa, old: Libc.sigaction_t; res, i: INTEGER;
-			(* sigstk: Libc.sigaltstack_t; *)
+			sigstk: Libc.stack_t;
+			errno: INTEGER;
 	BEGIN
-(* Linux: TODO
 		(* A. V. Shiryaev: Set alternative stack on which signals are to be processed *)
 			sigstk.ss_sp := Libc.calloc(1, sigStackSize);
 			IF sigstk.ss_sp # Libc.NULL THEN
@@ -1886,19 +1886,20 @@ MODULE Kernel;
 				sigstk.ss_flags := 0;
 				res := Libc.sigaltstack(sigstk, NIL);
 				IF res # 0 THEN Msg("ERROR: Kernel.InstallSignals: sigaltstack failed!");
+					S.GET( Libc.__errno_location(), errno );
+					Int(errno);
 					Libc.exit(1)
 				END
 			ELSE Msg("ERROR: malloc(SIGSTKSIZE) failed");
 				Libc.exit(1)
 			END;
-*)
 
 		sa.sa_sigaction := TrapHandler;
 (*
 		res := LinLibc.sigemptyset(S.ADR(sa.sa_mask));
 *)
 		res := Libc.sigfillset(S.ADR(sa.sa_mask));
-		sa.sa_flags := (* Libc.SA_ONSTACK + *) Libc.SA_SIGINFO; (* TrapHandler takes three arguments *)
+		sa.sa_flags := Libc.SA_ONSTACK + Libc.SA_SIGINFO; (* TrapHandler takes three arguments *)
 		(*
 		IF LinLibc.sigaction(LinLibc.SIGINT, sa, old) # 0 THEN Msg("failed to install SIGINT") END;
 		IF LinLibc.sigaction(LinLibc.SIGILL, sa, old) # 0 THEN Msg("failed to install SIGILL") END;

BIN
BlackBox/Linux/Lin/Mod/Libc.odc


+ 4 - 0
BlackBox/Linux/Lin/Mod/Libc.txt

@@ -239,6 +239,8 @@ MODULE LinLibc ["libc.so.6"];
 
 		_SC_PAGESIZE* = 30;
 
+		SIGSTKSZ* = 8192;
+
 	TYPE 
 		__ftw_func_t* = PROCEDURE (fileName: PtrSTR; VAR [nil] stat: stat_t; flag: INTEGER): INTEGER;
 		PtrVoid* = INTEGER;
@@ -452,5 +454,7 @@ MODULE LinLibc ["libc.so.6"];
 	PROCEDURE [ccall] getenv* (name: PtrSTR): PtrSTR;
 
 	PROCEDURE [ccall] sysconf* (name: INTEGER): INTEGER;
+	
+	PROCEDURE [ccall] sigaltstack* (VAR [nil] ss: stack_t; VAR [nil] oss: stack_t): INTEGER;
 
 END LinLibc.

BIN
BlackBox/Linux/libBB.so


BIN
BlackBox/Linux/libBB0.so


BIN
BlackBox/OpenBSD/Lin/Mod/Kernel.odc


+ 3 - 0
BlackBox/OpenBSD/Lin/Mod/Kernel.txt

@@ -1966,6 +1966,7 @@ MODULE Kernel;
 			sigStackSize = Libc.SIGSTKSZ;
 		VAR sa, old: Libc.sigaction_t; res, i: INTEGER;
 			sigstk: Libc.sigaltstack_t;
+			 errno: INTEGER;
 	BEGIN
 		(* A. V. Shiryaev: Set alternative stack on which signals are to be processed *)
 			sigstk.ss_sp := Libc.calloc(1, sigStackSize);
@@ -1974,6 +1975,8 @@ MODULE Kernel;
 				sigstk.ss_flags := 0;
 				res := Libc.sigaltstack(sigstk, NIL);
 				IF res # 0 THEN Msg("ERROR: Kernel.InstallSignals: sigaltstack failed!");
+					S.GET( Libc.__errno_location(), errno );
+					Int(errno);
 					Libc.exit(1)
 				END
 			ELSE Msg("ERROR: malloc(SIGSTKSIZE) failed");

BIN
BlackBox/OpenBSD/libBB.so


BIN
BlackBox/OpenBSD/libBB0.so


+ 2 - 3
README

@@ -58,7 +58,6 @@ Files:
 				mmap: use "/dev/zero" device instead of -1
 				mprotect addresses must be page-aligned
 				do not show warning message if signal install failed
-				sigaltstack
 		OpenBSD/Lin/Mod/linHostFiles.odc:
 			OpenBUGS Lin/Mod/linHostFiles.odc:
 				OpenBSD-specific:
@@ -80,8 +79,8 @@ Files:
 				OpenBSD-specific
 		Linux/Lin/Mod/Libc.odc:
 			OpenBUGS Lin/Mod/Libc.odc:
-				PROT_*, MAP_*, O_*, _SC_PAGESIZE CONSTs added
-				open, close, read, write, mmap, munmap, mprotect, getenv, sysconf functions added
+				PROT_*, MAP_*, O_*, _SC_PAGESIZE, SIGSTKSZ CONSTs added
+				open, close, read, write, mmap, munmap, mprotect, getenv, sysconf, sigaltstack functions added
 		Linux/Lin/Mod/Dl.odc:
 			OpenBUGS Lin/Mod/Dl.odc
 		OpenBSD/Lin/Mod/Dates.odc: