github.com/keybase/client/go@v0.0.0-20241007131713-f10651d043c8/kbfs/sysutils/pid_path_linux.go (about)

     1  // Copyright 2017 Keybase Inc. All rights reserved.
     2  // Use of this source code is governed by a BSD
     3  // license that can be found in the LICENSE file.
     4  
     5  package sysutils
     6  
     7  import (
     8  	"fmt"
     9  	"os"
    10  )
    11  
    12  // GetExecPathFromPID returns the process's executable path for given PID.
    13  func GetExecPathFromPID(pid uint32) (string, error) {
    14  	return os.Readlink(fmt.Sprintf("/proc/%d/exe", pid))
    15  }