File tree 1 file changed +10
-9
lines changed
1 file changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -40,25 +40,26 @@ type Creator interface {
40
40
New (ctx context.Context , args ... string ) (Process , error )
41
41
}
42
42
43
- type exeProcessCreator struct {
44
- exePath string
45
- }
43
+ type CmdCreatorFunc func (ctx context.Context , args ... string ) (* exec.Cmd , error )
46
44
47
45
// NewCreator creates a Creator for external Tor process execution based on the
48
46
// given exe path.
49
47
func NewCreator (exePath string ) Creator {
50
- return & exeProcessCreator {exePath }
48
+ return CmdCreatorFunc (func (ctx context.Context , args ... string ) (* exec.Cmd , error ) {
49
+ cmd := exec .CommandContext (ctx , exePath , args ... )
50
+ cmd .Stdout = os .Stdout
51
+ cmd .Stderr = os .Stderr
52
+ return cmd , nil
53
+ })
51
54
}
52
55
53
56
type exeProcess struct {
54
57
* exec.Cmd
55
58
}
56
59
57
- func (e * exeProcessCreator ) New (ctx context.Context , args ... string ) (Process , error ) {
58
- cmd := exec .CommandContext (ctx , e .exePath , args ... )
59
- cmd .Stdout = os .Stdout
60
- cmd .Stderr = os .Stderr
61
- return & exeProcess {cmd }, nil
60
+ func (c CmdCreatorFunc ) New (ctx context.Context , args ... string ) (Process , error ) {
61
+ cmd , err := c (ctx , args ... )
62
+ return & exeProcess {cmd }, err
62
63
}
63
64
64
65
// ErrControlConnUnsupported is returned by Process.EmbeddedControlConn when
You can’t perform that action at this time.
0 commit comments