Skip to content

Commit

Permalink
sigaltstack corrected
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Shiryaev committed Sep 26, 2012
1 parent 339d32a commit 9fcf0c8
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 9 deletions.
Binary file modified BlackBox/Linux/Lin/Mod/Kernel.odc
Binary file not shown.
13 changes: 7 additions & 6 deletions BlackBox/Linux/Lin/Mod/Kernel.txt
Expand Up @@ -1873,32 +1873,33 @@ 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
sigstk.ss_size := sigStackSize;
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;
Expand Down
Binary file modified BlackBox/Linux/Lin/Mod/Libc.odc
Binary file not shown.
4 changes: 4 additions & 0 deletions BlackBox/Linux/Lin/Mod/Libc.txt
Expand Up @@ -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;
Expand Down Expand Up @@ -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.
Binary file modified BlackBox/Linux/libBB.so
Binary file not shown.
Binary file modified BlackBox/Linux/libBB0.so
Binary file not shown.
Binary file modified BlackBox/OpenBSD/Lin/Mod/Kernel.odc
Binary file not shown.
3 changes: 3 additions & 0 deletions BlackBox/OpenBSD/Lin/Mod/Kernel.txt
Expand Up @@ -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);
Expand All @@ -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");
Expand Down
Binary file modified BlackBox/OpenBSD/libBB.so
Binary file not shown.
Binary file modified BlackBox/OpenBSD/libBB0.so
Binary file not shown.
5 changes: 2 additions & 3 deletions README
Expand Up @@ -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:
Expand All @@ -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:
Expand Down

0 comments on commit 9fcf0c8

Please sign in to comment.