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

Windows incompatibility in mpf game spawn process #25

Open
bosh opened this issue Feb 24, 2025 · 6 comments
Open

Windows incompatibility in mpf game spawn process #25

bosh opened this issue Feb 24, 2025 · 6 comments

Comments

@bosh
Copy link

bosh commented Feb 24, 2025

When using the Godot editor option "Launch MPF with GMC" on Windows, the Godot instance and MPF game instance both run, but there is an error in the followup process in godot code.

E 0:00:03:0833   process.gd:94 @ _check_mpf(): Could not create child process: ps 18988 -o "state="
  <C++ Error>    Condition "ret == 0" is true. Returning: ERR_CANT_FORK
  <C++ Source>   platform/windows/os_windows.cpp:947 @ execute()
  <Stack Trace>  process.gd:94 @ _check_mpf()

That's from this chunk of code

func _check_mpf():
	# Detect if the pid is still alive
	self.log.debug("Checking MPF PID %s...", mpf_pid)
	var output = []
	OS.execute("ps", [mpf_pid, "-o", "state="], output, true, true)

called from _spawn_mpf as the launch healthcheck.

I tried running ps <pid> -o "state=" in my mingw window and in powershell, and the ps command exists, but has issues in either shell (in cmd it doesnt exist at all). In mingw I get ps: unknown option -- o. In powershell it's a longer error starting with: Get-Process : Parameter cannot be processed because the parameter name 'o' is ambiguous. Possible matches include: -OutVariable -OutBuffer.

Is there something we could replace the o option with that would be more cross-platform compatible? I haven't done research yet, maybe tomorrow.

This issue was first spotted in discord in another user's debugging of unrelated gmc game-specific config problems, but then I replicated it in my current minimal gmc-integrated game as well.

@bosh
Copy link
Author

bosh commented Feb 24, 2025

The odd thing with this exception is that the GMC window moves on to attract just fine, and then to base mode/etc. as expected. Nothing seems to have stopped working or be otherwise amiss, and I never had to press use the "Pause Running Project" button to unpause (as I have in some previous GMC crashes I've seen)

@avanwinkle
Copy link
Contributor

Mmm, unfortunately I don't have a good machine to test this on but maybe making some of the flags platform-dependent? If you can get a working command to run, we can branch the behavior based on that!

@bosh
Copy link
Author

bosh commented Feb 27, 2025

Yeah for sure. What's the expected behavior of -o "state=" for you? And is that Mac or Linux? (Hopefully the same on both)

@founfabug
Copy link

The -o option looks like an older BSD command, maybe mac?

Windows
On windows 10, under cmd and powershell, the following line returns true (0) if mpf has launched:
tasklist /FI "PID eq 25036"|find "mpf.exe"
find is required as tasklist does not return error codes of value to us. find does have some good filter options, but seems to only report 'unknown' as a status for mpf.exe

To avoid complexity of launching a shell to enable the pipe , consider testing the return text from tasklist directly, with No Headers option:

PS C:\tmp> tasklist /FI "PID eq 25036" /NH

mpf.exe                      25036 Console                    1      3,996 K

Note, it looks like we are gifted a newline before output.

Linux
On linux, ps -q 25036 should do the job, tested with latest Lubuntu LTS so should be good for all Ubuntu variations.

@bosh
Copy link
Author

bosh commented Feb 27, 2025

Looks like OS.get_name() will identify the platform -- https://docs.godotengine.org/en/stable/classes/class_os.html#class-os-method-get-name

I played with OS.execute to see what shell Godot actually calls to -- seems like it's CMD. (Looks like we can force powershell or any other command using execute

I can put together a patch with the platform detect and nix/windows variants per @founfabug and test it on Windows and maybe a ubuntu as well. Do either of you have a Mac? I'll default mac to the same as Linux for now.

@founfabug
Copy link

From my reading the mac ps command does not support the -q option, and the existing -o line won't do the job either.
https://www.unix.com/man_page/osx/1/ps/ shows the osx ps command accepting a -p pid option that looks promising. That page is silent on exit codes, however BSD man pages advise the the command exits 0 on success, and >0 if an error occurs, so it should work as expected.

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

3 participants