Skip to content

Commit

Permalink
Fix nil panic on Windows
Browse files Browse the repository at this point in the history
ps.FindProcess(1) returns nil,nil if the PID is not found.

Signed-off-by: Sune Keller <absukl@almbrand.dk>
  • Loading branch information
sirlatrom authored and HeavyWombat committed Mar 4, 2021
1 parent 277c7f6 commit ffacbe6
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion term.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ func IsTrueColor() bool {
// IsGardenContainer returns whether the current process is started in the
// process tree of garden container (https://github.com/cloudfoundry/garden).
func IsGardenContainer() bool {
if process, err := ps.FindProcess(1); err == nil {
if process, err := ps.FindProcess(1); err == nil && process != nil {
switch process.Executable() {
case "garden-init":
return true
Expand Down

0 comments on commit ffacbe6

Please sign in to comment.