This repository has been archived by the owner on Nov 9, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4dd617c
commit 254b074
Showing
5 changed files
with
127 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package cmds | ||
|
||
import ( | ||
"io" | ||
"os/exec" | ||
"syscall" | ||
) | ||
|
||
func KillPID(pid int) (int, error) { | ||
// https://stackoverflow.com/questions/22470193/why-wont-go-kill-a-child-process-correctly | ||
err := syscall.Kill(pid, syscall.SIGKILL) | ||
return pid, err | ||
} | ||
|
||
func StartCmd(cmd string) (*exec.Cmd, io.ReadCloser, io.ReadCloser, error) { | ||
var err error | ||
c := exec.Command("/bin/sh", "-c", cmd) | ||
c.SysProcAttr = &syscall.SysProcAttr{Setsid: true} | ||
stderr, err := c.StderrPipe() | ||
if err != nil { | ||
return nil, nil, nil, err | ||
} | ||
stdout, err := c.StdoutPipe() | ||
if err != nil { | ||
return nil, nil, nil, err | ||
} | ||
err = c.Start() | ||
if err != nil { | ||
return nil, nil, nil, err | ||
} | ||
return c, stdout, stderr, err | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
package cmds | ||
|
||
// Version tale版本信息 | ||
type Version struct { | ||
LatestVersion string `json:"latest_version"` | ||
PublishTime int `json:"publish_time"` | ||
Hash string `json:"hash"` | ||
ChangeLogs []string `json:"change_logs"` | ||
DownloadURL string `json:"download_url"` | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters