Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Change
This PR adds a new exported function in System.Process:
getCurrentPid
.This calls
getCurrentProcessId
from System.Win32.Process on Windows, andgetProcessID
from System.Posix.Process on POSIX systems.Rationale
This seems like an oversight considering
getPid
is implemented already. I sometimes require the current running program's process ID. Currently, I have to do the CPP conditional logic myself every time, which is a pain. Putting this inprocess
seems natural.Furthermore, my understanding of
process
is that it is a unified interface to System.Win32.Process and System.Posix.Process. As both modules provide a function to "get the currently executing process id", I feel it makes sense to have a cross-platform wrapper function.Remaining Issues
The
@since
field has been left as a TODO since I'm not sure what version this will be merged in.Tests
I could not come up with a method to test the PR. Unlike with the test for
getPid
, there's nothing to compare the value against, I think. It's worked from my past experiences in personal projects.I wasn't able to ensure a stable setup to test to begin with, as running the existing test suite
stack test
on the Windows version of Stack failed due to several reasons (getPid
failing, anddetatch_console
failing). Any feedback or insight is therefore appreciated.