summaryrefslogtreecommitdiff
path: root/lib/sys
diff options
context:
space:
mode:
authorOri Bernstein <ori@markovcorp.com>2017-06-12 17:39:34 -0700
committerOri Bernstein <ori@markovcorp.com>2017-06-12 17:39:34 -0700
commit8fffc0be8c026118884aa4685246c797927f38b9 (patch)
tree728b7f4cf212620184738f4ebb3097e27400e77f /lib/sys
parent99e1677b6bf577fb4db18f50a92df79ea47e9e0e (diff)
downloadmc-8fffc0be8c026118884aa4685246c797927f38b9.tar.gz
Signals now work right on linux.
We weren't calling the restorer. Linux really wants this. Oops.
Diffstat (limited to 'lib/sys')
-rw-r--r--lib/sys/sys+linux-x64.myr12
-rw-r--r--lib/sys/syscall+linux-x64.s4
2 files changed, 14 insertions, 2 deletions
diff --git a/lib/sys/sys+linux-x64.myr b/lib/sys/sys+linux-x64.myr
index 7f7760b..1d79151 100644
--- a/lib/sys/sys+linux-x64.myr
+++ b/lib/sys/sys+linux-x64.myr
@@ -52,7 +52,7 @@ pkg sys =
;;
type sigset = struct
- bits : uint32[2]
+ bits : uint32[2]
;;
type sigaction = struct
@@ -343,6 +343,7 @@ pkg sys =
const Sanocldstop : sigflags = 0x00000001
const Sanocldwait : sigflags = 0x00000002
const Sasiginfo : sigflags = 0x00000004
+ const Sarestorer : sigflags = 0x04000000
const Saonstack : sigflags = 0x08000000
const Sarestart : sigflags = 0x10000000
const Sanodefer : sigflags = 0x40000000
@@ -699,6 +700,7 @@ pkg sys =
/* getting to the os */
extern const syscall : (sc:scno, args:... -> int64)
+ extern const sigreturn : (-> void)
/* process management */
const exit : (status:int -> void)
@@ -879,7 +881,13 @@ const pipe = {fds; -> syscall(Syspipe, a(fds))}
const dup = {fd; -> (syscall(Sysdup, a(fd)) : fd)}
const dup2 = {src, dst; -> (syscall(Sysdup2, a(src), a(dst)) : fd)}
-const sigaction = {sig, act, oact; -> (syscall(Sysrt_sigaction, a(sig), a(act), a(oact), a(sizeof(sigflags))) : int)}
+const sigaction = {sig, act, oact;
+ if act.restore == (0 : byte#)
+ act.flags |= Sarestorer
+ act.restore = (sys.sigreturn : byte#)
+ ;;
+ -> (syscall(Sysrt_sigaction, a(sig), a(act), a(oact), a(sizeof(sigflags))) : int)
+}
const sigprocmask = {sig, act, oact; -> (syscall(Sysrt_sigprocmask, a(sig), a(act), a(oact), a(sizeof(sigflags))) : int)}
/* threading */
diff --git a/lib/sys/syscall+linux-x64.s b/lib/sys/syscall+linux-x64.s
index 8637ede..88fb7ca 100644
--- a/lib/sys/syscall+linux-x64.s
+++ b/lib/sys/syscall+linux-x64.s
@@ -50,3 +50,7 @@ sys$fnclone:
popq %r15
ret
+.globl sys$sigreturn
+sys$sigreturn:
+ movq $15,%rax
+ syscall