Skip to content

Commit

Permalink
Improved Windows compatibility
Browse files Browse the repository at this point in the history
Signed-off-by: Arthur Sengileyev <[email protected]>
  • Loading branch information
arixmkii committed Aug 23, 2022
1 parent d97f4df commit f87f6d2
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion cmd/rootlessport/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,7 @@ outer:

// https://github.com/containers/podman/issues/11248
// Copy /dev/null to stdout and stderr to prevent SIGPIPE errors
if f, err := os.OpenFile("/dev/null", os.O_WRONLY, 0755); err == nil {
if f, err := os.OpenFile(os.DevNull, os.O_WRONLY, 0755); err == nil {
unix.Dup2(int(f.Fd()), 1) //nolint:errcheck
unix.Dup2(int(f.Fd()), 2) //nolint:errcheck
f.Close()
Expand Down
4 changes: 2 additions & 2 deletions pkg/machine/pull.go
Original file line number Diff line number Diff line change
Expand Up @@ -213,8 +213,8 @@ func decompressXZ(src string, output io.WriteCloser) error {
var read io.Reader
var cmd *exec.Cmd
// Prefer xz utils for fastest performance, fallback to go xi2 impl
if _, err := exec.LookPath("xzcat"); err == nil {
cmd = exec.Command("xzcat", "-k", src)
if _, err := exec.LookPath("xz"); err == nil {
cmd = exec.Command("xz", "-d", "-c", "-k", src)
read, err = cmd.StdoutPipe()
if err != nil {
return err
Expand Down
8 changes: 4 additions & 4 deletions pkg/machine/qemu/machine.go
Original file line number Diff line number Diff line change
Expand Up @@ -545,12 +545,12 @@ func (v *MachineVM) Start(name string, _ machine.StartOptions) error {
return err
}
defer fd.Close()
dnr, err := os.OpenFile("/dev/null", os.O_RDONLY, 0755)
dnr, err := os.OpenFile(os.DevNull, os.O_RDONLY, 0755)
if err != nil {
return err
}
defer dnr.Close()
dnw, err := os.OpenFile("/dev/null", os.O_WRONLY, 0755)
dnw, err := os.OpenFile(os.DevNull, os.O_WRONLY, 0755)
if err != nil {
return err
}
Expand Down Expand Up @@ -1216,11 +1216,11 @@ func (v *MachineVM) startHostNetworking() (string, apiForwardingState, error) {
}

attr := new(os.ProcAttr)
dnr, err := os.OpenFile("/dev/null", os.O_RDONLY, 0755)
dnr, err := os.OpenFile(os.DevNull, os.O_RDONLY, 0755)
if err != nil {
return "", noForwarding, err
}
dnw, err := os.OpenFile("/dev/null", os.O_WRONLY, 0755)
dnw, err := os.OpenFile(os.DevNull, os.O_WRONLY, 0755)
if err != nil {
return "", noForwarding, err
}
Expand Down

0 comments on commit f87f6d2

Please sign in to comment.