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

PowerShell command does not die #54

Closed
Sauraus opened this issue Jul 10, 2013 · 7 comments
Closed

PowerShell command does not die #54

Sauraus opened this issue Jul 10, 2013 · 7 comments

Comments

@Sauraus
Copy link

Sauraus commented Jul 10, 2013

NOTE: Not sure if this is a childprocess issue or Powershell.

The following Powershell command will echo and then exit if executed in a CMD shell, however if the same is invoked through childprocess this doesn't happen.

PS> echo hello; exit $LASTEXITCODE

@jarib
Copy link
Collaborator

jarib commented Jul 10, 2013

Please include the code you're using to run PowerShell and CMD through ChildProcess.

@Sauraus
Copy link
Author

Sauraus commented Jul 10, 2013

@jarib
Copy link
Collaborator

jarib commented Jul 11, 2013

Can you reproduce the problem without the Vagrant wrapper? What do you mean by "does not die" - do you see powershell.exe in the machine's process list?

ChildProcess is not executing the command in a shell, it is executing powershell.exe directly through the CreateProcess system call. You're passing [";", "exit", "$LASTEXITCODE"] as arguments to powershell.exe. Is that the intention?

I don't have a windows machine to try this on at the moment, but if you want anything interpreted as in cmd.exe, you'll have to invoke the interpreter yourself, e.g. something like:

process = ChildProcess.build("cmd.exe", "/c", "powershell Expand-Archive ...")
process.start

@Sauraus
Copy link
Author

Sauraus commented Jul 11, 2013

Correct powershell.exe remains running as a child process long after the Expand-Archive has finished, which I can see in process explorer.

I tried the ;exit $LASTEXITCODE for force the powershell.exe process to terminate after running the command Expand-Archive.

PowerShell has the equivalent of cmd.exe /c being PowerShell.exe -Command but even if I use that something in the way how ChildProcess spawns powershell keeps it from exiting when done.

@jarib
Copy link
Collaborator

jarib commented Jul 11, 2013

I very much doubt the problem is ChildProcess. Have you tried passing the -NonInteractive flag to PowerShell (from http://technet.microsoft.com/en-us/library/hh847736.aspx)?

@jarib
Copy link
Collaborator

jarib commented Jul 11, 2013

Also, your gist does not use -Command flag. You should try that:

ChildProcess.build("PowerShell.exe", "-Command", "the full command in a string")

@jarib
Copy link
Collaborator

jarib commented Aug 14, 2013

Going to close this since there's no response in a month.

@jarib jarib closed this as completed Aug 14, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants