Skip to content

Process runs the wrong executable on Windows #70028

Open
@dabrahams

Description

@dabrahams

Description

Process() doesn't launch the right executable on Windows.

Steps to reproduce

Compile and run this program on a standard Windows installation.

import Foundation
let p = Process()

p.executableURL = URL(fileURLWithPath: #"C:\Windows\System32\cmd.exe"#)
p.arguments = ["/?"]

do {
  try p.run()
  p.waitUntilExit()
}
catch let e { fatalError("0. threw \(e)") }
if p.terminationStatus != 0 { fatalError("0. exit status: \(p.terminationStatus)") }

Expected behavior
Prints the output of running c:\Windows\System32\cmd.exe /? and fatal errors with a nonzero exit status.

Actual behavior
Prints the output of running c:\Windows\System32\MKDIR.exe /? and fatal errors with a nonzero exit status.

Environment
swift --version
compnerd.org Swift version 5.9-dev (LLVM 466a716843b7efb, Swift 39bac1c)
Target: x86_64-unknown-windows-msvc

Metadata

Metadata

Assignees

No one assigned

    Labels

    FoundationWindowsPlatform: WindowsbugA deviation from expected or documented behavior. Also: expected but undesirable behavior.triage neededThis issue needs more specific labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions