forked from VojtechVitek/rerun
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path_cmdlinux.go
More file actions
53 lines (42 loc) · 892 Bytes
/
_cmdlinux.go
File metadata and controls
53 lines (42 loc) · 892 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package rerun
import (
"fmt"
"os"
"os/exec"
)
// NOTE: not in use.. darwin seems to work on darwin and linux
type LinuxCmd struct {
*command
}
var _ Command = &DarwinCmd{}
func NewLinuxCmd(args ...string) *LinuxCmd {
return &LinuxCmd{command: &command{args: args}}
}
func (c *LinuxCmd) Start() error {
cmd := exec.Command("/bin/sh", append([]string{"-c"}, c.args...)...)
cmd.Stdout = os.Stdout
cmd.Stderr = os.Stderr
cmd.Stdin = os.Stdin
if err := cmd.Start(); err != nil {
return err
}
c.cmd = cmd
return nil
}
func (c *LinuxCmd) Kill() error {
return c.cmd.Process.Kill()
}
func (c *LinuxCmd) Wait() error {
// Wait for the process to finish.
return c.cmd.Wait()
}
func (c *LinuxCmd) PID() string {
if c.cmd != nil {
return fmt.Sprintf("PID %v", c.cmd.Process.Pid)
} else {
return "PID unknown"
}
}
func (c *LinuxCmd) String() string {
return c.PID()
}