mirror of
https://github.com/containers/podman.git
synced 2025-06-22 09:58:10 +08:00
Buildtag out unix commands for common OS files
Unix only code crept into shared portions of the machine codebase, preventing builds on Windows. Move them into unix-only files. [NO NEW TESTS NEEDED] Signed-off-by: Ashley Cui <acui@redhat.com>
This commit is contained in:
@ -28,7 +28,6 @@ import (
|
||||
"github.com/containers/storage/pkg/lockfile"
|
||||
"github.com/digitalocean/go-qemu/qmp"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/sys/unix"
|
||||
)
|
||||
|
||||
var (
|
||||
@ -589,15 +588,7 @@ func (v *MachineVM) qemuPid() (int, error) {
|
||||
logrus.Warnf("Reading QEMU pidfile: %v", err)
|
||||
return -1, nil
|
||||
}
|
||||
|
||||
if err := unix.Kill(pid, 0); err != nil {
|
||||
if err == unix.ESRCH {
|
||||
return -1, nil
|
||||
}
|
||||
return -1, fmt.Errorf("pinging QEMU process: %w", err)
|
||||
}
|
||||
|
||||
return pid, nil
|
||||
return findProcess(pid)
|
||||
}
|
||||
|
||||
// Start executes the qemu command line and forks it
|
||||
@ -970,7 +961,7 @@ func (v *MachineVM) Stop(_ string, _ machine.StopOptions) error {
|
||||
return stopErr
|
||||
}
|
||||
|
||||
if err := unix.Kill(qemuPid, unix.SIGKILL); err != nil {
|
||||
if err := sigKill(qemuPid); err != nil {
|
||||
if stopErr == nil {
|
||||
return err
|
||||
}
|
||||
|
@ -43,3 +43,17 @@ func extractTargetPath(paths []string) string {
|
||||
}
|
||||
return paths[0]
|
||||
}
|
||||
|
||||
func sigKill(pid int) error {
|
||||
return unix.Kill(pid, unix.SIGKILL)
|
||||
}
|
||||
|
||||
func findProcess(pid int) (int, error) {
|
||||
if err := unix.Kill(pid, 0); err != nil {
|
||||
if err == unix.ESRCH {
|
||||
return -1, nil
|
||||
}
|
||||
return -1, fmt.Errorf("pinging QEMU process: %w", err)
|
||||
}
|
||||
return pid, nil
|
||||
}
|
||||
|
@ -50,3 +50,11 @@ func extractTargetPath(paths []string) string {
|
||||
dedup := regexp.MustCompile(`//+`)
|
||||
return dedup.ReplaceAllLiteralString("/"+target, "/")
|
||||
}
|
||||
|
||||
func sigKill(pid int) error {
|
||||
return nil
|
||||
}
|
||||
|
||||
func findProcess(pid int) (int, error) {
|
||||
return -1, nil
|
||||
}
|
||||
|
Reference in New Issue
Block a user