proc.go 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. // Copyright 2009 The Go Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style
  3. // license that can be found in the LICENSE file.
  4. // Process etc.
  5. package os
  6. import (
  7. "runtime"
  8. "syscall"
  9. )
  10. // Args hold the command-line arguments, starting with the program name.
  11. var Args []string
  12. func init() {
  13. if runtime.GOOS == "windows" {
  14. // Initialized in exec_windows.go.
  15. return
  16. }
  17. Args = runtime_args()
  18. }
  19. func runtime_args() []string // in package runtime
  20. // Getuid returns the numeric user id of the caller.
  21. func Getuid() int { return syscall.Getuid() }
  22. // Geteuid returns the numeric effective user id of the caller.
  23. func Geteuid() int { return syscall.Geteuid() }
  24. // Getgid returns the numeric group id of the caller.
  25. func Getgid() int { return syscall.Getgid() }
  26. // Getegid returns the numeric effective group id of the caller.
  27. func Getegid() int { return syscall.Getegid() }
  28. // Getgroups returns a list of the numeric ids of groups that the caller belongs to.
  29. func Getgroups() ([]int, error) {
  30. gids, e := syscall.Getgroups()
  31. return gids, NewSyscallError("getgroups", e)
  32. }
  33. // Exit causes the current program to exit with the given status code.
  34. // Conventionally, code zero indicates success, non-zero an error.
  35. // The program terminates immediately; deferred functions are
  36. // not run.
  37. func Exit(code int) { syscall.Exit(code) }