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

Tracking issue for std::process::id #44971

Closed
tmccombs opened this issue Oct 2, 2017 · 11 comments
Closed

Tracking issue for std::process::id #44971

tmccombs opened this issue Oct 2, 2017 · 11 comments
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-enhancement Category: An issue proposing an enhancement or a PR with one. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.

Comments

@tmccombs
Copy link
Contributor

tmccombs commented Oct 2, 2017

The standard library provides a way to get the process id of a child process with std::process::Child::id(), but doesn't have any way to get the current processes id (the equivalent of getpid).

It is possible to do this with libc::getpid, but it seems to me that this should be something that is part of the standard library, especially since it already has cross-platform support for process ids of child processes.

@TimNN TimNN added C-feature-request Category: A feature request, i.e: not implemented / a PR. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue. labels Oct 3, 2017
@sfackler
Copy link
Member

sfackler commented Oct 3, 2017

Seems reasonable to add!

@retep998
Copy link
Member

retep998 commented Oct 4, 2017

GetCurrentProcessId on Windows.

tmccombs added a commit to tmccombs/rust that referenced this issue Oct 6, 2017
kennytm added a commit to kennytm/rust that referenced this issue Oct 25, 2017
@sfackler sfackler reopened this Nov 19, 2017
@sfackler
Copy link
Member

Reopening as the tracking issue.

@sfackler sfackler added B-unstable Blocker: Implemented in the nightly compiler and unstable. and removed C-feature-request Category: A feature request, i.e: not implemented / a PR. labels Nov 19, 2017
@EdSchouten
Copy link
Contributor

EdSchouten commented Dec 28, 2017

While porting Rust over to CloudABI, a sandboxed UNIX-like runtime environment, I ran into the issue that there is no way for me to implement this function. As we're aiming to use CloudABI in distributed settings, there is no traditional 16/32-bit process identifier. Instead, processes may be identified by a UUID. This is useful, as integer process identifiers can easily collide when dealing with many instances of a job (due to the birthday paradox).

As this function was only introduced recently, would it still be possible to alter it to return an opaque, but displayable data type instead? That said, almost all of the other functions provided by this module are also broken on CloudABI. The traditional fork()/execve() model doesn't lend well to sandboxing. Maybe it makes more sense to disable std::process on CloudABI entirely.

@tmccombs
Copy link
Contributor Author

tmccombs commented Dec 28, 2017

I'm opposed a completely opaque data type, because that limits the usefulness. For example, that makes it difficult to use in C (or dbus) that require a PID. However, I think it would be alright if the it was a semi-opaque type with OS-specific API's to get the underlying representation (in std::os::unix, etc). However, that would break consistency with std::process::Child::id, which is already stabilized. I'm not sure how you would deal with that either.

@sfackler
Copy link
Member

As @tmccombs has mentioned, the ship has already sailed here due to Child::id. More generally, though. I'm not sure it makes sense to avoid supporting getpid of all things because some platform decided not to implement it.

@EdSchouten
Copy link
Contributor

One thing that would be low-hanging fruit would be to at least have some kind of type alias for this. On UNIX/Windows, it could be defined as i32. On CloudABI, it could be a string. That way, existing code that uses i32 continues to build on existing platforms, whereas less conventional platforms can choose to implement this function differently.

@XAMPPRocky XAMPPRocky added the C-enhancement Category: An issue proposing an enhancement or a PR with one. label Jan 22, 2018
@SimonSapin
Copy link
Contributor

Given this:

That said, almost all of the other functions provided by this module are also broken on CloudABI. The traditional fork()/execve() model doesn't lend well to sandboxing. Maybe it makes more sense to disable std::process on CloudABI entirely.

and this:

the ship has already sailed here due to Child::id

I’m inclined to stabilize std::process::id as-is. (Returning u32.)

@rfcbot fcp merge

Hopefully the portability lint can eventually help a CloudABI port to "cleanly" implement this differently, or not at all.

@rfcbot rfcbot added the proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. label Mar 17, 2018
@rfcbot
Copy link

rfcbot commented Mar 17, 2018

Team member @SimonSapin has proposed to merge this. The next step is review by the rest of the tagged teams:

No concerns currently listed.

Once a majority of reviewers approve (and none object), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!

See this document for info about what commands tagged team members can give me.

@SimonSapin SimonSapin changed the title getpid function Tracking issue for std::process::id Mar 17, 2018
@rfcbot rfcbot added final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. and removed proposed-final-comment-period Proposed to merge/close by relevant subteam, see T-<team> label. Will enter FCP once signed off. labels Mar 19, 2018
@rfcbot
Copy link

rfcbot commented Mar 19, 2018

🔔 This is now entering its final comment period, as per the review above. 🔔

@rfcbot
Copy link

rfcbot commented Mar 29, 2018

The final comment period is now complete.

bors pushed a commit that referenced this issue Apr 2, 2018
bors added a commit that referenced this issue Apr 2, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
B-unstable Blocker: Implemented in the nightly compiler and unstable. C-enhancement Category: An issue proposing an enhancement or a PR with one. final-comment-period In the final comment period and will be merged soon unless new substantive objections are raised. T-libs-api Relevant to the library API team, which will review and decide on the PR/issue.
Projects
None yet
Development

No branches or pull requests

8 participants