mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
44 lines
1.2 KiB
Go
44 lines
1.2 KiB
Go
// Copyright (C) 2019-2025, Lux Industries, Inc. All rights reserved.
|
|
// See the file LICENSE for licensing terms.
|
|
//
|
|
// This file is a derived work, based on the go-ethereum library whose original
|
|
// notices appear below.
|
|
//
|
|
// It is distributed under a license compatible with the licensing terms of the
|
|
// original code from which it is derived.
|
|
//
|
|
// Much love to the original authors for their work.
|
|
// **********
|
|
// This file originates from Docker/Moby,
|
|
// https://github.com/moby/moby/blob/master/pkg/reexec/
|
|
// Licensed under Apache License 2.0: https://github.com/moby/moby/blob/master/LICENSE
|
|
// Copyright 2013-2018 Docker, Inc.
|
|
|
|
//go:build !linux
|
|
|
|
package reexec
|
|
|
|
import (
|
|
"os"
|
|
"os/exec"
|
|
"path/filepath"
|
|
)
|
|
|
|
// Self returns the path to the current process's binary.
|
|
// Uses os.Args[0].
|
|
func Self() string {
|
|
name := os.Args[0]
|
|
if filepath.Base(name) == name {
|
|
if lp, err := exec.LookPath(name); err == nil {
|
|
return lp
|
|
}
|
|
}
|
|
// handle conversion of relative paths to absolute
|
|
if absName, err := filepath.Abs(name); err == nil {
|
|
return absName
|
|
}
|
|
// if we couldn't get absolute name, return original
|
|
// (NOTE: Go only errors on Abs() if os.Getwd fails)
|
|
return name
|
|
}
|