-
Notifications
You must be signed in to change notification settings - Fork 99
/
options.go
51 lines (40 loc) · 1.01 KB
/
options.go
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
package ptycmd
import (
"os"
"os/exec"
"syscall"
"time"
)
// Option is a configuration option for a Cmd
type Option func(*Cmd)
// Cmd is a shelled out command and an attached pty
type Cmd struct {
// the command that is being relayed
command string
// args passed to the command
argv []string
// the external command struct
cmd *exec.Cmd
// the pseudoterminal attached to the command
pty *os.File
// channel to signal closing the pty
ptyClosed chan struct{}
// signal to close process
closeSignal syscall.Signal
// time to wait to close process
closeTimeout time.Duration
}
// WithCloseSignal lets you specify the signal to send to the
// underlying process on close
func WithCloseSignal(signal syscall.Signal) Option {
return func(c *Cmd) {
c.closeSignal = signal
}
}
// WithCloseTimeout lets you specify how long to wait for the
// underlying process to terminate before sending a SIGKILL
func WithCloseTimeout(timeout time.Duration) Option {
return func(c *Cmd) {
c.closeTimeout = timeout
}
}