From: David Symonds Date: Mon, 25 May 2009 21:38:38 +0000 (-0700) Subject: Add os.Getpid and os.Getppid. X-Git-Tag: weekly.2009-11-06~1549 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=ce5bcbe37ff766b9fc6102a8e71925461af746ee;p=gostls13.git Add os.Getpid and os.Getppid. R=rsc APPROVED=rsc DELTA=11 (11 added, 0 deleted, 0 changed) OCL=29352 CL=29357 --- diff --git a/src/lib/os/exec.go b/src/lib/os/exec.go index 1fbd7e7aae..9f0f01e0a8 100644 --- a/src/lib/os/exec.go +++ b/src/lib/os/exec.go @@ -88,3 +88,14 @@ func Wait(pid int, options uint64) (w *Waitmsg, err Error) { return w, nil; } +// Getpid returns the process id of the caller. +func Getpid() int { + p, r2, e := syscall.Syscall(syscall.SYS_GETPID, 0, 0, 0); + return int(p) +} + +// Getppid returns the process id of the caller's parent. +func Getppid() int { + p, r2, e := syscall.Syscall(syscall.SYS_GETPPID, 0, 0, 0); + return int(p) +}