OLD | NEW |
1 // Copyright 2017 The LUCI Authors. All rights reserved. | 1 // Copyright 2017 The LUCI Authors. All rights reserved. |
2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
4 | 4 |
5 package venv | 5 package venv |
6 | 6 |
7 import ( | 7 import ( |
8 "os" | 8 "os" |
9 "path/filepath" | 9 "path/filepath" |
10 "syscall" | 10 "syscall" |
11 | 11 |
12 "github.com/luci/luci-go/common/errors" | 12 "github.com/luci/luci-go/common/errors" |
13 ) | 13 ) |
14 | 14 |
15 // longestGeneratedScriptPath returns the path of the longest generated script | 15 // longestGeneratedScriptPath returns the path of the longest generated script |
16 // given a VirtualEnv root. | 16 // given a VirtualEnv root. |
17 // | 17 // |
18 // Since Windows doesn't generate scripts, this is disabled. | 18 // Since Windows doesn't generate scripts, this is disabled. |
19 func longestGeneratedScriptPath(basedir string) string { return "" } | 19 func longestGeneratedScriptPath(basedir string) string { return "" } |
20 | 20 |
21 // venvBinDir resolves the path where VirtualEnv binaries are installed. | 21 // venvBinDir resolves the path where VirtualEnv binaries are installed. |
22 func venvBinDir(root string) string { | 22 func venvBinDir(root string) string { |
23 return filepath.Join(root, "Scripts") | 23 return filepath.Join(root, "Scripts") |
24 } | 24 } |
25 | 25 |
26 func checkProcessRunning(pid int) error { | 26 func checkProcessRunning(pid int) error { |
27 proc, err := os.FindProcess(pid) | 27 proc, err := os.FindProcess(pid) |
28 if err != nil { | 28 if err != nil { |
29 » » return errors.Annotate(err).Reason("failed to find process").Err
() | 29 » » return errors.Annotate(err, "failed to find process").Err() |
30 } | 30 } |
31 | 31 |
32 if err := proc.Signal(os.Signal(syscall.Signal(0))); err != nil { | 32 if err := proc.Signal(os.Signal(syscall.Signal(0))); err != nil { |
33 » » return errors.Annotate(err).Reason("failed to signal process").E
rr() | 33 » » return errors.Annotate(err, "failed to signal process").Err() |
34 } | 34 } |
35 return nil | 35 return nil |
36 } | 36 } |
OLD | NEW |