mirror of
https://github.com/containers/podman.git
synced 2025-08-01 07:40:22 +08:00

There are 2 things added. First there is added support for handling drive letters while doing value split. If drive letter is detected, then max number of elements will be increased by one, but then first two will be concatenated to reconstruct the path. Second part is basic, but working, conversion of Windows path to Unix path to be used, when target path is not explicitly specified. Signed-off-by: Arthur Sengileyev <arthur.sengileyev@gmail.com>
46 lines
1.0 KiB
Go
46 lines
1.0 KiB
Go
//go:build darwin || dragonfly || freebsd || linux || netbsd || openbsd
|
|
// +build darwin dragonfly freebsd linux netbsd openbsd
|
|
|
|
package qemu
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
"strings"
|
|
"syscall"
|
|
|
|
"golang.org/x/sys/unix"
|
|
)
|
|
|
|
func isProcessAlive(pid int) bool {
|
|
err := unix.Kill(pid, syscall.Signal(0))
|
|
if err == nil || err == unix.EPERM {
|
|
return true
|
|
}
|
|
return false
|
|
}
|
|
|
|
func checkProcessStatus(processHint string, pid int, stderrBuf *bytes.Buffer) error {
|
|
var status syscall.WaitStatus
|
|
pid, err := syscall.Wait4(pid, &status, syscall.WNOHANG, nil)
|
|
if err != nil {
|
|
return fmt.Errorf("failed to read qem%su process status: %w", processHint, err)
|
|
}
|
|
if pid > 0 {
|
|
// child exited
|
|
return fmt.Errorf("%s exited unexpectedly with exit code %d, stderr: %s", processHint, status.ExitStatus(), stderrBuf.String())
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func pathsFromVolume(volume string) []string {
|
|
return strings.SplitN(volume, ":", 3)
|
|
}
|
|
|
|
func extractTargetPath(paths []string) string {
|
|
if len(paths) > 1 {
|
|
return paths[1]
|
|
}
|
|
return paths[0]
|
|
}
|