-
-
Notifications
You must be signed in to change notification settings - Fork 21.4k
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
Add OS.get_process_exit_code()
method
#90358
Add OS.get_process_exit_code()
method
#90358
Conversation
9adfbe7
to
8f32c08
Compare
8f32c08
to
790cd26
Compare
|
Yeah, I forgot to update the description. |
790cd26
to
880b730
Compare
get_process_exit_code()
methodOS.get_process_exit_code()
method
The semantics of And calling not saying we need to change the design necessarily, but it might be good to explain these points in the docs. (Or if someone else with good understanding of POSIX style APIs can offer a different explanation) |
It is the same for Windows (but instead of kernel, we keep process handles in the |
Would it make sense to cache the result of querying the exit code or whether the process is running so that calling it multiple times does not cause issues? Or if the OS signals the termination of the process somehow, automatically query and cache it so that those two methods just do system calls while the process is running, and provide the cached result otherwise? I don't know if that makes sense but it could be a more user-friendly API than purely exposing the system calls with their quirks. |
It might be worth caching status (in both if !OS.is_process_running(...):
int exit_code = OS.get_process_exit_code(...)
... |
880b730
to
847d5d0
Compare
I pushed caching for Windows, but I'm getting same results with and without it. |
847d5d0
to
9cca6b7
Compare
@bruvzg Should we add a similar process map to |
It should not be necessary on Windows, only for Unix (I guess as HashMap<pid, status> similarly to Windows process_map). |
9cca6b7
to
f393826
Compare
I pushed process map for Unix (not tested).
I made it a struct, because it needs information whether the process is still running (unless there is some exit code that can be assumed to never be returned from app?). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I am concerned about the additional complexity needed to support this order of operations. In particular, it needs to work from any thread.
Also if there is nothing to clean up data from this HashMap, will it leak?
My personal preference would be to keep the old design and document that you have to pick one or the other function. Use is_process_running only if you do not care about the exit code.
ac1130f
to
c0a12e9
Compare
c0a12e9
to
5c2ea79
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the same mutex should be added to Windows code as well. The rest seems fine.
5c2ea79
to
589abe9
Compare
Pushed Windows mutex. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing mutex lock
/unlock
around process_map->insert(pid, pi);
(2x) and MutextLock
in the kill
in the Windows code.
589abe9
to
dce4a3e
Compare
I forgot to save the file before pushing 🤦♂️ |
Thanks! |
Closes godotengine/godot-proposals#9471
The method is implemented for Windows, Linux, Mac OS, Android. I only tested Windows.