github.com/hashicorp/go-plugin@v1.6.0/internal/cmdrunner/process.go (about)

     1  // Copyright (c) HashiCorp, Inc.
     2  // SPDX-License-Identifier: MPL-2.0
     3  
     4  package cmdrunner
     5  
     6  import "time"
     7  
     8  // pidAlive checks whether a pid is alive.
     9  func pidAlive(pid int) bool {
    10  	return _pidAlive(pid)
    11  }
    12  
    13  // pidWait blocks for a process to exit.
    14  func pidWait(pid int) error {
    15  	ticker := time.NewTicker(1 * time.Second)
    16  	defer ticker.Stop()
    17  
    18  	for range ticker.C {
    19  		if !pidAlive(pid) {
    20  			break
    21  		}
    22  	}
    23  
    24  	return nil
    25  }