-
Notifications
You must be signed in to change notification settings - Fork 29.8k
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
Fix spawn of cmd and bat files on Windows #15217
Comments
I think this snippet from the C# code you referenced pretty much says it all:
A console window is still being created. So C# is really doing the same thing, except it is removing the window from the taskbar. |
Nice, that probably bodes well for a fix then because it means that nodejs isn't doing anything wrong in how it spawns, it's just not fully abstracted over this Windows-specific nuance? |
Libuv supports it (the |
Cool, is this something that can be exposed as another option to |
@atrauzzi if you follow the logic of |
I suspect it would make more sense for someone familiar with C++ dev to implement this. |
I've tested #15380 but it looks like it does not solve the issue. But I'm also not confident that I've tested the right thing. @atrauzzi could you provide a small example of how to reproduce the console popping? It would be great if it would be in pure Node.js, but since this looks related to the PM2 internals, an example that uses PM2 will work for now. |
Ping @atrauzzi. |
I put together a quick example as part of this ticket's initial description if that's enough? |
You mean this: https://gist.github.com/atrauzzi/bbcc171b57a7ea276a2e6bf6419c7e51 ? |
Yeah. |
How serendipitous 😄 this is what's been stopping me from using this in #14042 |
@atrauzzi the example looks like workaround the issue using edge-js. Could you provide some code that demonstrates the console window popping in and out? |
You can play with this module and flip the flags around in the node-native spawn: https://github.com/atrauzzi/gerty/blob/master/src/Spawn.ts#L15-L35 I can't remember off the top of my head at the moment what the correct combination is. But I believe there's a combination that results in a window popping open when it really shouldn't be. |
Well, an exact combination would be very helpful 😉. I'm not even sure what am I looking for, the more detailed instructions you provide the easier it will be for me to find the issue and fix it. |
After libuv PR it still looks like it does not work as intended. I've included libuv/libuv#1558 and #15380 in my Node build. I've included I've created an empty file |
This commit exposes the UV_PROCESS_WINDOWS_HIDE flag in Node as a windowsHide option to the child_process methods. The option is only applicable to Windows, and is ignored elsewhere. Fixes: nodejs#15217 PR-URL: nodejs#15380 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit exposes the UV_PROCESS_WINDOWS_HIDE flag in Node as a windowsHide option to the child_process methods. The option is only applicable to Windows, and is ignored elsewhere. Fixes: nodejs/node#15217 PR-URL: nodejs/node#15380 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit exposes the UV_PROCESS_WINDOWS_HIDE flag in Node as a windowsHide option to the child_process methods. The option is only applicable to Windows, and is ignored elsewhere. Fixes: nodejs#15217 PR-URL: nodejs#15380 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
This commit exposes the UV_PROCESS_WINDOWS_HIDE flag in Node as a windowsHide option to the child_process methods. The option is only applicable to Windows, and is ignored elsewhere. Backport-PR-URL: #16425 Fixes: #15217 PR-URL: #15380 Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl> Reviewed-By: James M Snell <jasnell@gmail.com>
Sorry, been very busy lately, but I just wanted to catch up -- Will the fix(es?) planned allow me to spawn a process with a shell, but without a window accompanying it? My main case here is that I need to have access to the default shell environment of the current user when spawning. |
Will cluster.fork honor this windowsHide eventually? It calls child_process.fork without this option for now I think. |
This ticket is specifically in reference to this: https://nodejs.org/api/child_process.html#child_process_spawning_bat_and_cmd_files_on_windows
I've put together a comparison as an example, basically it uses edgejs to spawn a command that's based off of a
cmd
file (electron): https://gist.github.com/atrauzzi/bbcc171b57a7ea276a2e6bf6419c7e51The point of the comparison is to show that it is possible to run
cmd
andbat
files without requiring a console window open the whole time. It would just be a matter of figuring out how .net is doing it and plugging into that same mechanism when running on Windows vs however nodejs is currently doing things.But I really think this issue is long overdue to be addressed.
cc. #556
The text was updated successfully, but these errors were encountered: