Implement all of os.Signal in arch-specific syscall
This is basically copied from `syscall_js.go` from the Go standard library, since the existing parts were from there as well.
Этот коммит содержится в:
родитель
e49e93f22c
коммит
bc098da93f
4 изменённых файлов: 66 добавлений и 0 удалений
|
@ -4,6 +4,7 @@
|
||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"internal/itoa"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -82,6 +83,20 @@ const (
|
||||||
SIGTERM Signal = 0xf
|
SIGTERM Signal = 0xf
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (s Signal) Signal() {}
|
||||||
|
|
||||||
|
func (s Signal) String() string {
|
||||||
|
if 0 <= s && int(s) < len(signals) {
|
||||||
|
str := signals[s]
|
||||||
|
if str != "" {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "signal " + itoa.Itoa(int(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
var signals = [...]string{}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Stdin = 0
|
Stdin = 0
|
||||||
Stdout = 1
|
Stdout = 1
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
|
import (
|
||||||
|
"internal/itoa"
|
||||||
|
)
|
||||||
|
|
||||||
// A Signal is a number describing a process signal.
|
// A Signal is a number describing a process signal.
|
||||||
// It implements the os.Signal interface.
|
// It implements the os.Signal interface.
|
||||||
type Signal int
|
type Signal int
|
||||||
|
@ -17,6 +21,20 @@ const (
|
||||||
SIGTERM
|
SIGTERM
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (s Signal) Signal() {}
|
||||||
|
|
||||||
|
func (s Signal) String() string {
|
||||||
|
if 0 <= s && int(s) < len(signals) {
|
||||||
|
str := signals[s]
|
||||||
|
if str != "" {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "signal " + itoa.Itoa(int(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
var signals = [...]string{}
|
||||||
|
|
||||||
// File system
|
// File system
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"internal/itoa"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -20,6 +21,20 @@ const (
|
||||||
SIGTERM = 15
|
SIGTERM = 15
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (s Signal) Signal() {}
|
||||||
|
|
||||||
|
func (s Signal) String() string {
|
||||||
|
if 0 <= s && int(s) < len(signals) {
|
||||||
|
str := signals[s]
|
||||||
|
if str != "" {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "signal " + itoa.Itoa(int(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
var signals = [...]string{}
|
||||||
|
|
||||||
const (
|
const (
|
||||||
Stdin = 0
|
Stdin = 0
|
||||||
Stdout = 1
|
Stdout = 1
|
||||||
|
|
|
@ -3,6 +3,10 @@
|
||||||
|
|
||||||
package syscall
|
package syscall
|
||||||
|
|
||||||
|
import (
|
||||||
|
"internal/itoa"
|
||||||
|
)
|
||||||
|
|
||||||
// Most code here has been copied from the Go sources:
|
// Most code here has been copied from the Go sources:
|
||||||
// https://github.com/golang/go/blob/go1.12/src/syscall/syscall_js.go
|
// https://github.com/golang/go/blob/go1.12/src/syscall/syscall_js.go
|
||||||
// It has the following copyright note:
|
// It has the following copyright note:
|
||||||
|
@ -25,6 +29,20 @@ const (
|
||||||
SIGTERM
|
SIGTERM
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func (s Signal) Signal() {}
|
||||||
|
|
||||||
|
func (s Signal) String() string {
|
||||||
|
if 0 <= s && int(s) < len(signals) {
|
||||||
|
str := signals[s]
|
||||||
|
if str != "" {
|
||||||
|
return str
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return "signal " + itoa.Itoa(int(s))
|
||||||
|
}
|
||||||
|
|
||||||
|
var signals = [...]string{}
|
||||||
|
|
||||||
// File system
|
// File system
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
|
Загрузка…
Создание таблицы
Сослаться в новой задаче