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

SceneTree.quit() ignores given exit code with --script #88055

Closed
razcore-rad opened this issue Feb 7, 2024 · 3 comments · Fixed by #89229
Closed

SceneTree.quit() ignores given exit code with --script #88055

razcore-rad opened this issue Feb 7, 2024 · 3 comments · Fixed by #89229

Comments

@razcore-rad
Copy link
Contributor

Tested versions

  • Reproducible in: 4.2.1.stable.official.b09f793f5, 4.2.2.rc1.official.c7fb0645a

System information

Ubuntu 23.10, Vulkan, NVIDIA GeForce RTX™ 2060 / NVIDIA GeForce RTX™ 2060

Issue description

The following code:

extends SceneTree


func _init() -> void:
	quit(1)

saved as dev.gd, when ran with godot --headless --script dev.gd always returns with a 0 exit code:

❯ godot --headless --script dev.gd | complete
╭───────────┬──────────────────────────────────────────────────────────────────────╮
│ stdout    │ Godot Engine v4.2.2.rc1.official.c7fb0645a - https://godotengine.org │
│           │                                                                      │
│           │                                                                      │
│ exit_code │ 0                                                                    │
╰───────────┴──────────────────────────────────────────────────────────────────────╯

Steps to reproduce

Check issue description.

Minimal reproduction project (MRP)

not applicable

@akien-mga akien-mga changed the title SceneTree.quit() always ignores given exit code SceneTree.quit() ignores given exit code with --headless --script Feb 7, 2024
@akien-mga akien-mga changed the title SceneTree.quit() ignores given exit code with --headless --script SceneTree.quit() ignores given exit code with --script Feb 7, 2024
@akien-mga
Copy link
Member

I can reproduce it with --script, but not when running an actual project.

@LeoBelda
Copy link
Contributor

I can't reproduce it on Windows.
It seems to be caused by a call to OS::set_exit_code in the Linux main:

if (Main::start()) {
os.set_exit_code(EXIT_SUCCESS);
os.run(); // it is actually the OS that decides how to run
}

Copying this line into Windows widechar_main allowed me to reproduce the issue: the exit code set by the script during the execution of Main::start gets overridden.

@akien-mga
Copy link
Member

Fixed by #89229.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants