Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Process runs the wrong executable on Windows #70028

Open
dabrahams opened this issue Nov 26, 2023 · 1 comment
Open

Process runs the wrong executable on Windows #70028

dabrahams opened this issue Nov 26, 2023 · 1 comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Foundation triage needed This issue needs more specific labels Windows Platform: Windows

Comments

@dabrahams
Copy link
Collaborator

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

@dabrahams dabrahams added bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. triage needed This issue needs more specific labels Foundation Windows Platform: Windows labels Nov 26, 2023
@WindowsMEMZ
Copy link
Contributor

@dabrahams What will happen if you try to start another program? For example, if you try to run regedit.exe, is Swift still start MKDIR.exe, or it works well?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug A deviation from expected or documented behavior. Also: expected but undesirable behavior. Foundation triage needed This issue needs more specific labels Windows Platform: Windows
Projects
None yet
Development

No branches or pull requests

2 participants