github.com/reiver/go@v0.0.0-20150109200633-1d0c7792f172/src/os/proc.go (about)

     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  
     5  // Process etc.
     6  
     7  package os
     8  
     9  import (
    10  	"runtime"
    11  	"syscall"
    12  )
    13  
    14  // Args hold the command-line arguments, starting with the program name.
    15  var Args []string
    16  
    17  func init() {
    18  	if runtime.GOOS == "windows" {
    19  		// Initialized in exec_windows.go.
    20  		return
    21  	}
    22  	Args = runtime_args()
    23  }
    24  
    25  func runtime_args() []string // in package runtime
    26  
    27  // Getuid returns the numeric user id of the caller.
    28  func Getuid() int { return syscall.Getuid() }
    29  
    30  // Geteuid returns the numeric effective user id of the caller.
    31  func Geteuid() int { return syscall.Geteuid() }
    32  
    33  // Getgid returns the numeric group id of the caller.
    34  func Getgid() int { return syscall.Getgid() }
    35  
    36  // Getegid returns the numeric effective group id of the caller.
    37  func Getegid() int { return syscall.Getegid() }
    38  
    39  // Getgroups returns a list of the numeric ids of groups that the caller belongs to.
    40  func Getgroups() ([]int, error) {
    41  	gids, e := syscall.Getgroups()
    42  	return gids, NewSyscallError("getgroups", e)
    43  }
    44  
    45  // Exit causes the current program to exit with the given status code.
    46  // Conventionally, code zero indicates success, non-zero an error.
    47  // The program terminates immediately; deferred functions are
    48  // not run.
    49  func Exit(code int) { syscall.Exit(code) }