mirror of
https://github.com/tinygo-org/tinygo.git
synced 2026-08-12 06:53:40 +00:00
os: implement process related functions
This commit implements various process related functions like os.Getuid() and os.Getpid(). It also implements or improves this support in the syscall package if it isn't available yet.
This commit is contained in:
committed by
Ron Evans
parent
e65592599c
commit
75298bb84b
@@ -1,6 +1,18 @@
|
||||
package os
|
||||
|
||||
import "syscall"
|
||||
|
||||
type Signal interface {
|
||||
String() string
|
||||
Signal() // to distinguish from other Stringers
|
||||
}
|
||||
|
||||
// Getpid returns the process id of the caller, or -1 if unavailable.
|
||||
func Getpid() int {
|
||||
return syscall.Getpid()
|
||||
}
|
||||
|
||||
// Getppid returns the process id of the caller's parent, or -1 if unavailable.
|
||||
func Getppid() int {
|
||||
return syscall.Getppid()
|
||||
}
|
||||
|
||||
@@ -196,8 +196,3 @@ func Readlink(name string) (string, error) {
|
||||
func TempDir() string {
|
||||
return "/tmp"
|
||||
}
|
||||
|
||||
// Getpid is a stub (for now), always returning 1
|
||||
func Getpid() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
@@ -24,3 +24,31 @@ func runtime_args() []string // in package runtime
|
||||
func Exit(code int) {
|
||||
syscall.Exit(code)
|
||||
}
|
||||
|
||||
// Getuid returns the numeric user id of the caller.
|
||||
//
|
||||
// On non-POSIX systems, it returns -1.
|
||||
func Getuid() int {
|
||||
return syscall.Getuid()
|
||||
}
|
||||
|
||||
// Geteuid returns the numeric effective user id of the caller.
|
||||
//
|
||||
// On non-POSIX systems, it returns -1.
|
||||
func Geteuid() int {
|
||||
return syscall.Geteuid()
|
||||
}
|
||||
|
||||
// Getgid returns the numeric group id of the caller.
|
||||
//
|
||||
// On non-POSIX systems, it returns -1.
|
||||
func Getgid() int {
|
||||
return syscall.Getgid()
|
||||
}
|
||||
|
||||
// Getegid returns the numeric effective group id of the caller.
|
||||
//
|
||||
// On non-POSIX systems, it returns -1.
|
||||
func Getegid() int {
|
||||
return syscall.Getegid()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user