FAQ

On 2012/10/26 16:36:37, r wrote:
is your name minuxName?
good point. PTAL.

btw, how to implement this on Plan 9?

https://codereview.appspot.com/6736069/

Search Discussions

  • Rob Pike at Oct 28, 2012 at 3:48 pm
    The file names are inappropriate now.

    For Plan 9, it depends what you want this for. /proc/PID/text is
    always a working name for the executable. Otherwise I don't know if
    it's possible.

    -rob
  • Minux Ma at Oct 28, 2012 at 3:57 pm

    On 2012/10/28 15:48:45, r wrote:
    The file names are inappropriate now.
    do you have suggestions for the filenames? i think executable is
    a bit too long, and exec might confuse with the exec syscall.
    how about the original execpath?
    For Plan 9, it depends what you want this for. /proc/PID/text is
    always a working name for the executable. Otherwise I don't know if
    it's possible.
    I've thought about /proc/PID/text, in fact it can pass the test, but
    i think the main use of this to determine the original binary's path
    so that the binary can access its bundled asset files, for example.

    i'd also like to test we can indeed find the other files around the
    binary, but given the current go test's behavior, this is difficult
    to test.

    https://codereview.appspot.com/6736069/
  • Minux Ma at Oct 28, 2012 at 5:43 pm
    PTAL.

    Patch Set 24 is the same as Patch Set 23 except
    s/progpath/executable/ in filenames.

    https://codereview.appspot.com/6736069/
  • R at Oct 28, 2012 at 5:47 pm
    i'm still not convinced by the idea behind this. the idea seems
    intrinsically too unportable to be elevated to the standard library. i
    expect to be outvoted.




    https://codereview.appspot.com/6736069/diff/43014/src/pkg/os/executable.go
    File src/pkg/os/executable.go (right):

    https://codereview.appspot.com/6736069/diff/43014/src/pkg/os/executable.go#newcode7
    src/pkg/os/executable.go:7: // Executable returns the absolute pathname
    of the current
    "the absolute pathname" sounds definitive but is actually not
    well-defined.

    https://codereview.appspot.com/6736069/diff/43014/src/pkg/os/executable_darwin.go
    File src/pkg/os/executable_darwin.go (right):

    https://codereview.appspot.com/6736069/diff/43014/src/pkg/os/executable_darwin.go#newcode7
    src/pkg/os/executable_darwin.go:7: var progPath string // set by
    ../runtime/progpath_darwin.c
    you've still got some progpaths around, in different casings.

    https://codereview.appspot.com/6736069/
  • Minux Ma at Oct 28, 2012 at 6:18 pm
    On 2012/10/28 17:47:49, r wrote:
    https://codereview.appspot.com/6736069/diff/43014/src/pkg/os/executable.go#newcode7
    src/pkg/os/executable.go:7: // Executable returns the absolute
    pathname of the
    current
    "the absolute pathname" sounds definitive but is actually not
    well-defined.
    i agree it is difficult to define its precise behavior.
    however, i think the following description is reasonable:
    the return value of Executable is an absolute path that matches the path
    used
    to launch the executable (assuming no one is modifying the intermediate
    paths).

    https://codereview.appspot.com/6736069/diff/43014/src/pkg/os/executable_darwin.go#newcode7
    src/pkg/os/executable_darwin.go:7: var progPath string // set by
    ../runtime/progpath_darwin.c
    you've still got some progpaths around, in different casings.
    All fixed.

    https://codereview.appspot.com/6736069/
  • Anthony Martin at Oct 29, 2012 at 1:14 am

    minux.ma@gmail.com once said:
    On 2012/10/26 16:36:37, r wrote:
    is your name minuxName?
    good point. PTAL.

    btw, how to implement this on Plan 9?
    func executable() (string, error) {
    f, err := Open("/proc/" + itoa(Getpid()) + "/text")
    if err != nil {
    return "", err
    }
    defer f.Close()
    return syscall.Fd2path(int(f.Fd()))
    }

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-dev @
categoriesgo
postedOct 28, '12 at 3:43p
activeOct 29, '12 at 1:14a
posts7
users3
websitegolang.org

3 users in discussion

Minux Ma: 4 posts R: 2 posts Anthony Martin: 1 post

People

Translate

site design / logo © 2022 Grokbase