Skip to content

Commit f9f678b

Browse files
authored
Merge pull request #32 from dballard/hidewindows
Hide the tor dos window on windows
2 parents 1c71414 + 75338db commit f9f678b

File tree

1 file changed

+10
-9
lines changed

1 file changed

+10
-9
lines changed

process/process.go

+10-9
Original file line numberDiff line numberDiff line change
@@ -40,25 +40,26 @@ type Creator interface {
4040
New(ctx context.Context, args ...string) (Process, error)
4141
}
4242

43-
type exeProcessCreator struct {
44-
exePath string
45-
}
43+
type CmdCreatorFunc func(ctx context.Context, args ...string) (*exec.Cmd, error)
4644

4745
// NewCreator creates a Creator for external Tor process execution based on the
4846
// given exe path.
4947
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+
})
5154
}
5255

5356
type exeProcess struct {
5457
*exec.Cmd
5558
}
5659

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
6263
}
6364

6465
// ErrControlConnUnsupported is returned by Process.EmbeddedControlConn when

0 commit comments

Comments
 (0)