Skip to content

[rcore] Process manipulation API for Windows and POSIX-compliant platforms#5822

Open
konakona418 wants to merge 4 commits intoraysan5:masterfrom
konakona418-forked:process-api
Open

[rcore] Process manipulation API for Windows and POSIX-compliant platforms#5822
konakona418 wants to merge 4 commits intoraysan5:masterfrom
konakona418-forked:process-api

Conversation

@konakona418
Copy link
Copy Markdown
Contributor

I noticed that in the wishlist for raylib7.0 (#5710) there are plans for process manipulation APIs, so I wrote the following functions for posix-compliant platforms:

  • InitProcess to launch a new process
  • CheckProcess which checks whether a process is still running
  • PauseProcess to pause execution
  • CloseProcess to terminate a process

And a counterpart for PauseProcess: ResumeProcess

Please let me know if any changes need to be made!

@konakona418 konakona418 changed the title [rcore] Process manipulation API for posix-compliant platfroms [rcore] Process manipulation API for posix-compliant platforms Apr 29, 2026
@konakona418
Copy link
Copy Markdown
Contributor Author

There have been a few updates, so I will squash them together

@konakona418 konakona418 force-pushed the process-api branch 2 times, most recently from e51f360 to 24b36ef Compare April 29, 2026 11:28
@raysan5
Copy link
Copy Markdown
Owner

raysan5 commented Apr 29, 2026

@konakona418 thanks for working on this addition, I think it still requires some work but it's a good start... Windows support should definitely be there...

@konakona418
Copy link
Copy Markdown
Contributor Author

Hi @raysan5
Thanks for the quick reply! I'll work on it right away...

@konakona418
Copy link
Copy Markdown
Contributor Author

konakona418 commented Apr 29, 2026

Hello @raysan5

I just implemented the API for Windows except for PauseProcess and ResumeProcess (I'll explain this right away). I tested the functions with MinGW cross compiler and Wine and the functions seem to be working just fine. However I'm not sure if that result will remain the same when it comes to a actual Windows device because sadly, I don't have a Windows laptop around right now...

And about this patch some questions remain:

  • I embedded the real struct definitions for calling CreateProcessA inside the InitProcess function, and for declaration of CreateProcessA I used a implicit struct declaration. I hard-coded some Win32 constants and attached their meanings in the comment. I handled this in a way similar to other Win32 imports to prevent polluting the namespace, but I'm not sure if I've done that in a proper manner...
  • InitProcess uses a static buffer to concat cmdline arguments, but I believe MAX_PATH * 4 is sufficient for most cases, and there's a bound check which will abort if overflow takes place
  • The reason why pause and resume is not implemented yet is that, if we want to achieve that, rather we iterate over all the threads and use API like SuspendThread or dynamically load some ntdll internal functions, and on this topic I really want to ask for your opinion
  • I tried to stick to the convention, but please let me know if any persists

Please let me know if more adjustments are required!

@konakona418 konakona418 changed the title [rcore] Process manipulation API for posix-compliant platforms [rcore] Process manipulation API for Windows and POSIX-compliant platforms Apr 29, 2026
Copy link
Copy Markdown
Contributor

@orcmid orcmid left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As difficult as it might appear, shouldn't these be handled at the platform level?

Perhaps there is no meaningful POSIX distinction with respect to platforms?

@konakona418
Copy link
Copy Markdown
Contributor Author

Hi @orcmid

Currently I followed the existing method applied to a few similar functions in rcore.c, which handles platforms via #if defined(...) macros directly. Regarding POSIX platforms, while there are subtle differences between Linux, macOS and BSDs, the basic APIs used here such as fork(), execvp(), waitpid(), and kill() behave consistently enough for the scope of this process API. If we need more platform-specific or advanced APIs, we will certainly need to introduce more fine-grained distinction.

@konakona418
Copy link
Copy Markdown
Contributor Author

Hello @raysan5

I finished working on process suspension and resuming just now, in which i dynamically loaded and used the ntdll internal functions NtSuspendProcess and NtResumeProcess. I also have done some cleanup as well. The implementation appears to be working correctly in my tests.

But still, I'm not sure whether dynamic loading Nt* functions is a good idea for raylib or not. What's your opinion?

@konakona418 konakona418 force-pushed the process-api branch 2 times, most recently from d472b7e to fc3cac5 Compare May 4, 2026 14:12
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 this pull request may close these issues.

3 participants