Skip to content

[Process] [New Feature] Identifying current process #12615

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

Open
thedarknomad opened this issue Mar 22, 2025 · 2 comments · May be fixed by #12666
Open

[Process] [New Feature] Identifying current process #12615

thedarknomad opened this issue Mar 22, 2025 · 2 comments · May be fixed by #12666

Comments

@thedarknomad
Copy link

thedarknomad commented Mar 22, 2025

Please consider adding a "SDL_GetCurrentProcessId()" and "SDL_GetCurrentProcessName()" implementation.

  • SDL_GetCurrentProcessId would return the current pid
  • SDL_GetCurrentProcessName would return the executable name

Both should be cached, since they're static, with the second maybe saved alongside the current executable path.

Alternative:

  • GetCurrentProcess returning a SDL_Process structure with the properties being the current pid and a new property being the process name (SDL.process.name)

Obviously, I can imagine this is low-prio compared to other bugs or requests, but it'd be appreciated if you kept it in mind, as since most operating systems are posix-based, it shouldn't be hard to implement cross-platform.

Use cases:

  • log file to match the exe
  • maybe monitoring the current process via the id
  • some files with local config files that match the exe for games that allow modding (and would duplicate executables)
  • the current pid might be useful if the current SDL process API will extend to more functions
  • adding a failsafe in SDL_KillProcess that it should return and fail if the process is the one that is the current process
  • maybe some games want to verify that users didn't tamper or execute any executables that are not approved by the game (i.e. patched for some cheats and having a separately patched exe so that Steam or other platforms don't overwrite it)
  • other use cases that don't come to mind atm :)
@thedarknomad thedarknomad changed the title [Process] [Request] Identifying current process [Process] [New Feature] Identifying current process Mar 22, 2025
@Semphriss
Copy link
Contributor

Leaving this here; SDL_GetBasePath implementations have code that fetch the path to the running executable seemingly on most platforms (at least Unix and Windows). For the PID, it would be GetCurrentProcessId on Windows and getpid on POSIX.

@thedarknomad
Copy link
Author

thedarknomad commented Mar 23, 2025

Indeed. As for consoles and mobile devices maybe the workaround could be using args[0] and stripping it from absolute/relative paths captured from main().

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

Successfully merging a pull request may close this issue.

2 participants