github.com/containers/podman/v4@v4.9.4/pkg/machine/qemu/machine_windows.go (about)

     1  package qemu
     2  
     3  import (
     4  	"bytes"
     5  	"fmt"
     6  	"regexp"
     7  	"strings"
     8  
     9  	"github.com/containers/podman/v4/pkg/machine"
    10  )
    11  
    12  func isProcessAlive(pid int) bool {
    13  	if checkProcessStatus("process", pid, nil) == nil {
    14  		return true
    15  	}
    16  	return false
    17  }
    18  
    19  func checkProcessStatus(processHint string, pid int, stderrBuf *bytes.Buffer) error {
    20  	active, exitCode := machine.GetProcessState(pid)
    21  	if !active {
    22  		if stderrBuf != nil {
    23  			return fmt.Errorf("%s exited unexpectedly, exit code: %d stderr: %s", processHint, exitCode, stderrBuf.String())
    24  		} else {
    25  			return fmt.Errorf("%s exited unexpectedly, exit code: %d", processHint, exitCode)
    26  		}
    27  	}
    28  	return nil
    29  }
    30  
    31  func pathsFromVolume(volume string) []string {
    32  	paths := strings.SplitN(volume, ":", 3)
    33  	driveLetterMatcher := regexp.MustCompile(`^(?:\\\\[.?]\\)?[a-zA-Z]$`)
    34  	if len(paths) > 1 && driveLetterMatcher.MatchString(paths[0]) {
    35  		paths = strings.SplitN(volume, ":", 4)
    36  		paths = append([]string{paths[0] + ":" + paths[1]}, paths[2:]...)
    37  	}
    38  	return paths
    39  }
    40  
    41  func extractTargetPath(paths []string) string {
    42  	if len(paths) > 1 {
    43  		return paths[1]
    44  	}
    45  	target := strings.ReplaceAll(paths[0], "\\", "/")
    46  	target = strings.ReplaceAll(target, ":", "/")
    47  	if strings.HasPrefix(target, "//./") || strings.HasPrefix(target, "//?/") {
    48  		target = target[4:]
    49  	}
    50  	dedup := regexp.MustCompile(`//+`)
    51  	return dedup.ReplaceAllLiteralString("/"+target, "/")
    52  }
    53  
    54  func sigKill(pid int) error {
    55  	return nil
    56  }
    57  
    58  func findProcess(pid int) (int, error) {
    59  	return -1, nil
    60  }