{"action":"created","comment":{"url":"https://api.github.com/repos/kardianos/osext/pulls/comments/43951496","id":43951496,"diff_hunk":"@@ -0,0 +1,96 @@\n+// Copyright 2012 The Go Authors. All rights reserved.\n+// Use of this source code is governed by a BSD-style\n+// license that can be found in the LICENSE file.\n+\n+package osext\n+\n+import (\n+\t\"fmt\"\n+\t\"os\"\n+\t\"os/exec\"\n+\t\"path/filepath\"\n+\t\"syscall\"\n+\t\"unsafe\"\n+)\n+\n+var initCwd, initCwdErr = os.Getwd()\n+\n+func executable() (string, error) {\n+\tvar mib [4]int32\n+\tmib = [4]int32{1 /* CTL_KERN */, 55 /* KERN_PROC_ARGS */, int32(os.Getpid()), 1 /* KERN_PROC_ARGV */}\n+\n+\tn := uintptr(0)\n+\t// get length\n+\t_, _, errNum := syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(unsafe.Pointer(&mib[0])), 4, 0, uintptr(unsafe.Pointer(&n)), 0, 0)\n+\tif errNum != 0 {\n+\t\treturn \"\", errNum\n+\t}\n+\tif n == 0 { // shouldn't happen\n+\t\treturn \"\", nil\n+\t}\n+\tbuf := make([]byte, n)\n+\t_, _, errNum = syscall.Syscall6(syscall.SYS___SYSCTL, uintptr(unsafe.Pointer(&mib[0])), 4, uintptr(unsafe.Pointer(&buf[0])), uintptr(unsafe.Pointer(&n)), 0, 0)\n+\tif errNum != 0 {\n+\t\treturn \"\", errNum\n+\t}\n+\tif n == 0 { // shouldn't happen\n+\t\treturn \"\", nil\n+\t}\n+\n+\t// buf now contains **argv, with pointers to each of the C-style NULL terminated arguments.\n+\tvar args []string\n+\targv := uintptr(unsafe.Pointer(&buf[0]))\n+\tfor {\n+\t\targp := *(**[1<<20]byte)(unsafe.Pointer(argv))\n+\t\tif argp == nil {\n+\t\t\tbreak\n+\t\t}\n+\t\tfor i := 0; uintptr(i) < n; i++ {\n+\t\t\tif argp[i] != 0 {\n+\t\t\t\tcontinue\n+\t\t\t}\n+\t\t\targs = append(args, string(argp[:i]))\n+\t\t\tn -= uintptr(i)\n+\t\t\tbreak\n+\t\t}\n+\t\tif n < unsafe.Sizeof(argv) {\n+\t\t\tbreak\n+\t\t}\n+\t\targv += unsafe.Sizeof(argv)\n+\t\tn -= unsafe.Sizeof(argv)\n+\t}\n+\n+\tvar err error\n+\texecPath := string(fmt.Sprintf(\"%s\", args[0]))","path":"osext_openbsd.go","position":64,"original_position":64,"commit_id":"f2a23e4c84012d28281ce30a769baffe81c0fc03","original_commit_id":"f2a23e4c84012d28281ce30a769baffe81c0fc03","user":{"login":"ajacoutot","id":1837947,"avatar_url":"https://avatars.githubusercontent.com/u/1837947?v=3","gravatar_id":"","url":"https://api.github.com/users/ajacoutot","html_url":"https://github.com/ajacoutot","followers_url":"https://api.github.com/users/ajacoutot/followers","following_url":"https://api.github.com/users/ajacoutot/following{/other_user}","gists_url":"https://api.github.com/users/ajacoutot/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacoutot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacoutot/subscriptions","organizations_url":"https://api.github.com/users/ajacoutot/orgs","repos_url":"https://api.github.com/users/ajacoutot/repos","events_url":"https://api.github.com/users/ajacoutot/events{/privacy}","received_events_url":"https://api.github.com/users/ajacoutot/received_events","type":"User","site_admin":false},"body":"Right, I'll fix it.","created_at":"2015-11-04T22:42:13Z","updated_at":"2015-11-04T22:42:13Z","html_url":"https://github.com/kardianos/osext/pull/11#discussion_r43951496","pull_request_url":"https://api.github.com/repos/kardianos/osext/pulls/11","_links":{"self":{"href":"https://api.github.com/repos/kardianos/osext/pulls/comments/43951496"},"html":{"href":"https://github.com/kardianos/osext/pull/11#discussion_r43951496"},"pull_request":{"href":"https://api.github.com/repos/kardianos/osext/pulls/11"}}},"pull_request":{"url":"https://api.github.com/repos/kardianos/osext/pulls/11","id":49728123,"html_url":"https://github.com/kardianos/osext/pull/11","diff_url":"https://github.com/kardianos/osext/pull/11.diff","patch_url":"https://github.com/kardianos/osext/pull/11.patch","issue_url":"https://api.github.com/repos/kardianos/osext/issues/11","number":11,"state":"open","locked":false,"title":"Unbreak support for OpenBSD.","user":{"login":"ajacoutot","id":1837947,"avatar_url":"https://avatars.githubusercontent.com/u/1837947?v=3","gravatar_id":"","url":"https://api.github.com/users/ajacoutot","html_url":"https://github.com/ajacoutot","followers_url":"https://api.github.com/users/ajacoutot/followers","following_url":"https://api.github.com/users/ajacoutot/following{/other_user}","gists_url":"https://api.github.com/users/ajacoutot/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacoutot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacoutot/subscriptions","organizations_url":"https://api.github.com/users/ajacoutot/orgs","repos_url":"https://api.github.com/users/ajacoutot/repos","events_url":"https://api.github.com/users/ajacoutot/events{/privacy}","received_events_url":"https://api.github.com/users/ajacoutot/received_events","type":"User","site_admin":false},"body":"Hi.\r\n\r\nCurrently osext is non-functional on OpenBSD (it fails looking into a non\r\nexisting /proc filesystem).\r\n\r\nThis patch allows me to use Packer. While being a \"best effort\" as I mentioned\r\nin my commit message, it worked in all my tests (wether the exec in is the path\r\nor called with its full path...).\r\nI did not add it to osext_sysctl.go on purpose because it's a bit too different\r\nand it would introduce some if/else and case mess.\r\n\r\nRegression test is happy as well:\r\n$ uname -mrsv                                                                   \r\nOpenBSD 5.8 GENERIC.MP#1553 amd64\r\n$ go test \r\nPASS\r\nok      _/home/cvs/github/osext 0.008s\r\n\r\nI'd be happy to hear any comment.\r\nThanks.","created_at":"2015-11-04T18:44:35Z","updated_at":"2015-11-04T22:42:13Z","closed_at":null,"merged_at":null,"merge_commit_sha":"78f5e21c598fa43fb5908a12ec5015c36af51942","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/kardianos/osext/pulls/11/commits","review_comments_url":"https://api.github.com/repos/kardianos/osext/pulls/11/comments","review_comment_url":"https://api.github.com/repos/kardianos/osext/pulls/comments{/number}","comments_url":"https://api.github.com/repos/kardianos/osext/issues/11/comments","statuses_url":"https://api.github.com/repos/kardianos/osext/statuses/f2a23e4c84012d28281ce30a769baffe81c0fc03","head":{"label":"ajacoutot:openbsd","ref":"openbsd","sha":"f2a23e4c84012d28281ce30a769baffe81c0fc03","user":{"login":"ajacoutot","id":1837947,"avatar_url":"https://avatars.githubusercontent.com/u/1837947?v=3","gravatar_id":"","url":"https://api.github.com/users/ajacoutot","html_url":"https://github.com/ajacoutot","followers_url":"https://api.github.com/users/ajacoutot/followers","following_url":"https://api.github.com/users/ajacoutot/following{/other_user}","gists_url":"https://api.github.com/users/ajacoutot/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacoutot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacoutot/subscriptions","organizations_url":"https://api.github.com/users/ajacoutot/orgs","repos_url":"https://api.github.com/users/ajacoutot/repos","events_url":"https://api.github.com/users/ajacoutot/events{/privacy}","received_events_url":"https://api.github.com/users/ajacoutot/received_events","type":"User","site_admin":false},"repo":{"id":45559084,"name":"osext","full_name":"ajacoutot/osext","owner":{"login":"ajacoutot","id":1837947,"avatar_url":"https://avatars.githubusercontent.com/u/1837947?v=3","gravatar_id":"","url":"https://api.github.com/users/ajacoutot","html_url":"https://github.com/ajacoutot","followers_url":"https://api.github.com/users/ajacoutot/followers","following_url":"https://api.github.com/users/ajacoutot/following{/other_user}","gists_url":"https://api.github.com/users/ajacoutot/gists{/gist_id}","starred_url":"https://api.github.com/users/ajacoutot/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ajacoutot/subscriptions","organizations_url":"https://api.github.com/users/ajacoutot/orgs","repos_url":"https://api.github.com/users/ajacoutot/repos","events_url":"https://api.github.com/users/ajacoutot/events{/privacy}","received_events_url":"https://api.github.com/users/ajacoutot/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/ajacoutot/osext","description":"Extensions to the standard \"os\" package. Executable and ExecutableFolder.","fork":true,"url":"https://api.github.com/repos/ajacoutot/osext","forks_url":"https://api.github.com/repos/ajacoutot/osext/forks","keys_url":"https://api.github.com/repos/ajacoutot/osext/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ajacoutot/osext/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ajacoutot/osext/teams","hooks_url":"https://api.github.com/repos/ajacoutot/osext/hooks","issue_events_url":"https://api.github.com/repos/ajacoutot/osext/issues/events{/number}","events_url":"https://api.github.com/repos/ajacoutot/osext/events","assignees_url":"https://api.github.com/repos/ajacoutot/osext/assignees{/user}","branches_url":"https://api.github.com/repos/ajacoutot/osext/branches{/branch}","tags_url":"https://api.github.com/repos/ajacoutot/osext/tags","blobs_url":"https://api.github.com/repos/ajacoutot/osext/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ajacoutot/osext/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ajacoutot/osext/git/refs{/sha}","trees_url":"https://api.github.com/repos/ajacoutot/osext/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ajacoutot/osext/statuses/{sha}","languages_url":"https://api.github.com/repos/ajacoutot/osext/languages","stargazers_url":"https://api.github.com/repos/ajacoutot/osext/stargazers","contributors_url":"https://api.github.com/repos/ajacoutot/osext/contributors","subscribers_url":"https://api.github.com/repos/ajacoutot/osext/subscribers","subscription_url":"https://api.github.com/repos/ajacoutot/osext/subscription","commits_url":"https://api.github.com/repos/ajacoutot/osext/commits{/sha}","git_commits_url":"https://api.github.com/repos/ajacoutot/osext/git/commits{/sha}","comments_url":"https://api.github.com/repos/ajacoutot/osext/comments{/number}","issue_comment_url":"https://api.github.com/repos/ajacoutot/osext/issues/comments{/number}","contents_url":"https://api.github.com/repos/ajacoutot/osext/contents/{+path}","compare_url":"https://api.github.com/repos/ajacoutot/osext/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ajacoutot/osext/merges","archive_url":"https://api.github.com/repos/ajacoutot/osext/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ajacoutot/osext/downloads","issues_url":"https://api.github.com/repos/ajacoutot/osext/issues{/number}","pulls_url":"https://api.github.com/repos/ajacoutot/osext/pulls{/number}","milestones_url":"https://api.github.com/repos/ajacoutot/osext/milestones{/number}","notifications_url":"https://api.github.com/repos/ajacoutot/osext/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ajacoutot/osext/labels{/name}","releases_url":"https://api.github.com/repos/ajacoutot/osext/releases{/id}","created_at":"2015-11-04T18:32:10Z","updated_at":"2015-11-04T18:32:11Z","pushed_at":"2015-11-04T19:24:39Z","git_url":"git://github.com/ajacoutot/osext.git","ssh_url":"git@github.com:ajacoutot/osext.git","clone_url":"https://github.com/ajacoutot/osext.git","svn_url":"https://github.com/ajacoutot/osext","homepage":null,"size":186,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"kardianos:master","ref":"master","sha":"6e7f843663477789fac7c02def0d0909e969b4e5","user":{"login":"kardianos","id":755121,"avatar_url":"https://avatars.githubusercontent.com/u/755121?v=3","gravatar_id":"","url":"https://api.github.com/users/kardianos","html_url":"https://github.com/kardianos","followers_url":"https://api.github.com/users/kardianos/followers","following_url":"https://api.github.com/users/kardianos/following{/other_user}","gists_url":"https://api.github.com/users/kardianos/gists{/gist_id}","starred_url":"https://api.github.com/users/kardianos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kardianos/subscriptions","organizations_url":"https://api.github.com/users/kardianos/orgs","repos_url":"https://api.github.com/users/kardianos/repos","events_url":"https://api.github.com/users/kardianos/events{/privacy}","received_events_url":"https://api.github.com/users/kardianos/received_events","type":"User","site_admin":false},"repo":{"id":31184284,"name":"osext","full_name":"kardianos/osext","owner":{"login":"kardianos","id":755121,"avatar_url":"https://avatars.githubusercontent.com/u/755121?v=3","gravatar_id":"","url":"https://api.github.com/users/kardianos","html_url":"https://github.com/kardianos","followers_url":"https://api.github.com/users/kardianos/followers","following_url":"https://api.github.com/users/kardianos/following{/other_user}","gists_url":"https://api.github.com/users/kardianos/gists{/gist_id}","starred_url":"https://api.github.com/users/kardianos/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kardianos/subscriptions","organizations_url":"https://api.github.com/users/kardianos/orgs","repos_url":"https://api.github.com/users/kardianos/repos","events_url":"https://api.github.com/users/kardianos/events{/privacy}","received_events_url":"https://api.github.com/users/kardianos/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/kardianos/osext","description":"Extensions to the standard \"os\" package. Executable and ExecutableFolder.","fork":false,"url":"https://api.github.com/repos/kardianos/osext","forks_url":"https://api.github.com/repos/kardianos/osext/forks","keys_url":"https://api.github.com/repos/kardianos/osext/keys{/key_id}","collaborators_url":"https://api.github.com/repos/kardianos/osext/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/kardianos/osext/teams","hooks_url":"https://api.github.com/repos/kardianos/osext/hooks","issue_events_url":"https://api.github.com/repos/kardianos/osext/issues/events{/number}","events_url":"https://api.github.com/repos/kardianos/osext/events","assignees_url":"https://api.github.com/repos/kardianos/osext/assignees{/user}","branches_url":"https://api.github.com/repos/kardianos/osext/branches{/branch}","tags_url":"https://api.github.com/repos/kardianos/osext/tags","blobs_url":"https://api.github.com/repos/kardianos/osext/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/kardianos/osext/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/kardianos/osext/git/refs{/sha}","trees_url":"https://api.github.com/repos/kardianos/osext/git/trees{/sha}","statuses_url":"https://api.github.com/repos/kardianos/osext/statuses/{sha}","languages_url":"https://api.github.com/repos/kardianos/osext/languages","stargazers_url":"https://api.github.com/repos/kardianos/osext/stargazers","contributors_url":"https://api.github.com/repos/kardianos/osext/contributors","subscribers_url":"https://api.github.com/repos/kardianos/osext/subscribers","subscription_url":"https://api.github.com/repos/kardianos/osext/subscription","commits_url":"https://api.github.com/repos/kardianos/osext/commits{/sha}","git_commits_url":"https://api.github.com/repos/kardianos/osext/git/commits{/sha}","comments_url":"https://api.github.com/repos/kardianos/osext/comments{/number}","issue_comment_url":"https://api.github.com/repos/kardianos/osext/issues/comments{/number}","contents_url":"https://api.github.com/repos/kardianos/osext/contents/{+path}","compare_url":"https://api.github.com/repos/kardianos/osext/compare/{base}...{head}","merges_url":"https://api.github.com/repos/kardianos/osext/merges","archive_url":"https://api.github.com/repos/kardianos/osext/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/kardianos/osext/downloads","issues_url":"https://api.github.com/repos/kardianos/osext/issues{/number}","pulls_url":"https://api.github.com/repos/kardianos/osext/pulls{/number}","milestones_url":"https://api.github.com/repos/kardianos/osext/milestones{/number}","notifications_url":"https://api.github.com/repos/kardianos/osext/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/kardianos/osext/labels{/name}","releases_url":"https://api.github.com/repos/kardianos/osext/releases{/id}","created_at":"2015-02-22T22:40:07Z","updated_at":"2015-11-03T12:22:13Z","pushed_at":"2015-11-04T19:24:39Z","git_url":"git://github.com/kardianos/osext.git","ssh_url":"git@github.com:kardianos/osext.git","clone_url":"https://github.com/kardianos/osext.git","svn_url":"https://github.com/kardianos/osext","homepage":null,"size":186,"stargazers_count":105,"watchers_count":105,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":14,"mirror_url":null,"open_issues_count":3,"forks":14,"open_issues":3,"watchers":105,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/kardianos/osext/pulls/11"},"html":{"href":"https://github.com/kardianos/osext/pull/11"},"issue":{"href":"https://api.github.com/repos/kardianos/osext/issues/11"},"comments":{"href":"https://api.github.com/repos/kardianos/osext/issues/11/comments"},"review_comments":{"href":"https://api.github.com/repos/kardianos/osext/pulls/11/comments"},"review_comment":{"href":"https://api.github.com/repos/kardianos/osext/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/kardianos/osext/pulls/11/commits"},"statuses":{"href":"https://api.github.com/repos/kardianos/osext/statuses/f2a23e4c84012d28281ce30a769baffe81c0fc03"}}}}