-
Notifications
You must be signed in to change notification settings - Fork 2
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
Not working on Windows 10 Home #3
Comments
At the moment I can't test this properly on Windows, so this is just my best guess. ntsuspend.suspend(child_process.exec('ffplay').pid); // suspends the shell Try to use |
I believe that you're correct. A little more digging showed some possible configurations, top three for me to try:
I'll let you know when I try these out later today. Thanks for your input. |
The difference isn't with tasklist.exe /FI "IMAGENAME eq ffplay.exe" /FO CSV /NH This is not ideal because of the assumption that the task found and parsed is the actual process one wants to manipulate. |
|
Ideally yes, but not in Windows 10 land. Regardless on the configuration there is always a shell. |
No, as specified by Node.js's docs |
The documentation is only correct when the command is 'node'. I strongly suggest that you prove to yourself that all other Windows' commands will create a shell regardless of the configuration. Have a good day. |
There is no such special case for Windows (nor an extra-special case to spawn Node.js on Windows). You can confirm this by checking Node.js's source code directly. (A shell will be spawned only if enabled, it's not platform dependent). https://github.com/nodejs/node/blob/master/lib/child_process.js#L504 You can also confirm that https://github.com/nodejs/node/blob/master/lib/child_process.js#L168 I've been using ntsuspend to suspend |
The following code works on my Windows 10 Home machine: const child_process = require('child_process');
const ntsuspend = require('ntsuspend');
const ffplay = child_process.spawn('ffplay', ['video.mkv']);
setTimeout(() => ntsuspend.suspend(ffplay.pid), 5000);
setTimeout(() => ntsuspend.resume(ffplay.pid), 10000); If this doesn't suspend ffplay the problem is somewhere else |
Thank you for testing and verifying on a Windows 10 Home system. That same code minus the file you are running 'video.mkv' produces these tasks on my system: tasklist.exe /FI "IMAGENAME eq ffplay.exe"
Image Name PID Session Name Session# Mem Usage
========================= ======== ================ =========== ============
ffplay.exe 63504 Console 1 12,264 K
ffplay.exe 44588 Console 1 34,308 K The second is the one needed. Only one 'ffplay.exe' is shown when the shell is 'powershell.exe'. May I ask what version of NodeJS you are running? My FFPlay version: ffplay version 4.2.2 Copyright (c) 2003-2019 the FFmpeg developers
built with gcc 9.2.1 (GCC) 20200122 I'll look into NodeJS configuration files and report back. I'll also add that my architecture is AMD64 (x86_64), with virtualization on in the BIOS and WSL 2 installed, |
Found the cause! It is how one installs the program being run. I installed 'ffmpeg' with Scoop which creates shims, those shims are then activated because of the PATH environment and then Scoop takes over to create a process for the installed program. That is why I was seeing two instances: the shim (returned PID) and the real process. Choco might have this effect too. What a headache to find this out. I created the issue here. Thanks for talking through this with me, you verifying something other than a 'node' process led me to look at other possibilities. |
I don't know how scoop uses this "proxy" process, but maybe it can be disabled. Anyway, I should probably clarify the use of |
For Scoop, there are three file extensions: exe, ps1, and shim all with the command name. My guess is that the exe reads one of the other two to get the real path and then that process is run passing on the arguments. There might be a way to turn it off but I will be relying on users to have it already or I install a local version for the application to work. At least there is a check that can be done to know if a possible shim has been used: |
I think you can use |
Yes, this is possible. For my purposes, I recommend users to install directly or use |
Great to find this project but in my test it did not work and both functions are returning 'true'. Here is my version info:
OS Name: Microsoft Windows 10 Home
OS Version: 10.0.19043 N/A Build 19043
Node Version: 14.2.0
What I tried:
Tried both cmd.exe and powershell.exe as shells.
Using 'exec' function from 'node:child_process' to play an audio file using 'ffplay'.
One thing I noticed is that the PID reported by node is not accessible from another shell to suspend using 'pssuspend'.
Will edit this when I try 'spawn' tomorrow. Please let me know how I can be of help.
The text was updated successfully, but these errors were encountered: