-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
if available use a Child's pidfd for kill/wait #117957
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(rustbot has picked a reviewer for you, use r? to override) |
rustbot
added
O-unix
Operating system: Unix-like
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
labels
Nov 16, 2023
@bors r+ |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Nov 18, 2023
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 19, 2023
if available use a Child's pidfd for kill/wait This should get us closer to stabilization of pidfds since they now do something useful. And they're `CLOEXEC` now. ``` $ strace -ffe clone,sendmsg,recvmsg,execve,kill,pidfd_open,pidfd_send_signal,waitpid,waitid ./x test std --no-doc -- pidfd [...] running 1 tests strace: Process 816007 attached [pid 816007] pidfd_open(816006, 0) = 3 [pid 816007] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f0c6b787990) = 816008 strace: Process 816008 attached [pid 816007] recvmsg(3, <unfinished ...> [pid 816008] pidfd_open(816008, 0) = 3 [pid 816008] sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 0 [pid 816007] <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[4]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 0 [pid 816008] execve("/usr/bin/false", ["false"], 0x7ffcf2100048 /* 105 vars */) = 0 [pid 816007] waitid(P_PIDFD, 4, <unfinished ...> [pid 816008] +++ exited with 1 +++ [pid 816007] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=816008, si_uid=1001, si_status=1, si_utime=0, si_stime=0}, WEXITED, NULL) = 0 [pid 816007] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=816008, si_uid=1001, si_status=1, si_utime=0, si_stime=0} --- [pid 816007] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLDstrace: Process 816009 attached , child_tidptr=0x7f0c6b787990) = 816009 [pid 816007] recvmsg(3, <unfinished ...> [pid 816009] pidfd_open(816009, 0) = 3 [pid 816009] sendmsg(5, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 0 [pid 816007] <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[5]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 0 [pid 816009] execve("/usr/bin/sleep", ["sleep", "1000"], 0x7ffcf2100048 /* 105 vars */) = 0 [pid 816007] waitid(P_PIDFD, 5, {}, WNOHANG|WEXITED, NULL) = 0 [pid 816007] pidfd_send_signal(5, SIGKILL, NULL, 0) = 0 [pid 816007] waitid(P_PIDFD, 5, <unfinished ...> [pid 816009] +++ killed by SIGKILL +++ [pid 816007] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=816009, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=0}, WEXITED, NULL) = 0 [pid 816007] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=816009, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=0} --- [pid 816007] +++ exited with 0 +++ ```
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
bors
added
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
and removed
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
labels
Nov 19, 2023
Looks like |
@bors r+ |
bors
added
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
and removed
S-waiting-on-review
Status: Awaiting review from the assignee but also interested parties.
labels
Nov 19, 2023
compiler-errors
added a commit
to compiler-errors/rust
that referenced
this pull request
Nov 20, 2023
if available use a Child's pidfd for kill/wait This should get us closer to stabilization of pidfds since they now do something useful. And they're `CLOEXEC` now. ``` $ strace -ffe clone,sendmsg,recvmsg,execve,kill,pidfd_open,pidfd_send_signal,waitpid,waitid ./x test std --no-doc -- pidfd [...] running 1 tests strace: Process 816007 attached [pid 816007] pidfd_open(816006, 0) = 3 [pid 816007] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f0c6b787990) = 816008 strace: Process 816008 attached [pid 816007] recvmsg(3, <unfinished ...> [pid 816008] pidfd_open(816008, 0) = 3 [pid 816008] sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 0 [pid 816007] <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[4]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 0 [pid 816008] execve("/usr/bin/false", ["false"], 0x7ffcf2100048 /* 105 vars */) = 0 [pid 816007] waitid(P_PIDFD, 4, <unfinished ...> [pid 816008] +++ exited with 1 +++ [pid 816007] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=816008, si_uid=1001, si_status=1, si_utime=0, si_stime=0}, WEXITED, NULL) = 0 [pid 816007] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=816008, si_uid=1001, si_status=1, si_utime=0, si_stime=0} --- [pid 816007] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLDstrace: Process 816009 attached , child_tidptr=0x7f0c6b787990) = 816009 [pid 816007] recvmsg(3, <unfinished ...> [pid 816009] pidfd_open(816009, 0) = 3 [pid 816009] sendmsg(5, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 0 [pid 816007] <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[5]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 0 [pid 816009] execve("/usr/bin/sleep", ["sleep", "1000"], 0x7ffcf2100048 /* 105 vars */) = 0 [pid 816007] waitid(P_PIDFD, 5, {}, WNOHANG|WEXITED, NULL) = 0 [pid 816007] pidfd_send_signal(5, SIGKILL, NULL, 0) = 0 [pid 816007] waitid(P_PIDFD, 5, <unfinished ...> [pid 816009] +++ killed by SIGKILL +++ [pid 816007] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=816009, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=0}, WEXITED, NULL) = 0 [pid 816007] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=816009, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=0} --- [pid 816007] +++ exited with 0 +++ ```
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 20, 2023
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#115526 (Add arm64e-apple-ios & arm64e-apple-darwin targets) - rust-lang#115691 (Add `$message_type` field to distinguish json diagnostic outputs) - rust-lang#117828 (Avoid iterating over hashmaps in astconv) - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`) - rust-lang#117957 (if available use a Child's pidfd for kill/wait) - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - rust-lang#118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 20, 2023
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#115526 (Add arm64e-apple-ios & arm64e-apple-darwin targets) - rust-lang#115691 (Add `$message_type` field to distinguish json diagnostic outputs) - rust-lang#117828 (Avoid iterating over hashmaps in astconv) - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`) - rust-lang#117957 (if available use a Child's pidfd for kill/wait) - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - rust-lang#118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 20, 2023
…mpiler-errors Rollup of 8 pull requests Successful merges: - rust-lang#117828 (Avoid iterating over hashmaps in astconv) - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`) - rust-lang#117957 (if available use a Child's pidfd for kill/wait) - rust-lang#117988 (Handle attempts to have multiple `cfg`d tail expressions) - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - rust-lang#118000 (Make regionck care about placeholders in outlives components) - rust-lang#118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 20, 2023
…tthiaskrgr Rollup of 8 pull requests Successful merges: - rust-lang#117828 (Avoid iterating over hashmaps in astconv) - rust-lang#117832 (interpret: simplify handling of shifts by no longer trying to handle signed and unsigned shift amounts in the same branch) - rust-lang#117891 (Recover `dyn` and `impl` after `for<...>`) - rust-lang#117957 (if available use a Child's pidfd for kill/wait) - rust-lang#117988 (Handle attempts to have multiple `cfg`d tail expressions) - rust-lang#117994 (Ignore but do not assume region obligations from unifying headers in negative coherence) - rust-lang#118000 (Make regionck care about placeholders in outlives components) - rust-lang#118068 (subtree update cg_gcc 2023/11/17) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Nov 20, 2023
Rollup merge of rust-lang#117957 - the8472:pidfd-wait, r=Mark-Simulacrum if available use a Child's pidfd for kill/wait This should get us closer to stabilization of pidfds since they now do something useful. And they're `CLOEXEC` now. ``` $ strace -ffe clone,sendmsg,recvmsg,execve,kill,pidfd_open,pidfd_send_signal,waitpid,waitid ./x test std --no-doc -- pidfd [...] running 1 tests strace: Process 816007 attached [pid 816007] pidfd_open(816006, 0) = 3 [pid 816007] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLD, child_tidptr=0x7f0c6b787990) = 816008 strace: Process 816008 attached [pid 816007] recvmsg(3, <unfinished ...> [pid 816008] pidfd_open(816008, 0) = 3 [pid 816008] sendmsg(4, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 0 [pid 816007] <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[4]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 0 [pid 816008] execve("/usr/bin/false", ["false"], 0x7ffcf2100048 /* 105 vars */) = 0 [pid 816007] waitid(P_PIDFD, 4, <unfinished ...> [pid 816008] +++ exited with 1 +++ [pid 816007] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=816008, si_uid=1001, si_status=1, si_utime=0, si_stime=0}, WEXITED, NULL) = 0 [pid 816007] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_EXITED, si_pid=816008, si_uid=1001, si_status=1, si_utime=0, si_stime=0} --- [pid 816007] clone(child_stack=NULL, flags=CLONE_CHILD_CLEARTID|CLONE_CHILD_SETTID|SIGCHLDstrace: Process 816009 attached , child_tidptr=0x7f0c6b787990) = 816009 [pid 816007] recvmsg(3, <unfinished ...> [pid 816009] pidfd_open(816009, 0) = 3 [pid 816009] sendmsg(5, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[3]}], msg_controllen=24, msg_flags=0}, 0) = 0 [pid 816007] <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="", iov_len=0}], msg_iovlen=1, msg_control=[{cmsg_len=20, cmsg_level=SOL_SOCKET, cmsg_type=SCM_RIGHTS, cmsg_data=[5]}], msg_controllen=24, msg_flags=MSG_CMSG_CLOEXEC}, MSG_CMSG_CLOEXEC) = 0 [pid 816009] execve("/usr/bin/sleep", ["sleep", "1000"], 0x7ffcf2100048 /* 105 vars */) = 0 [pid 816007] waitid(P_PIDFD, 5, {}, WNOHANG|WEXITED, NULL) = 0 [pid 816007] pidfd_send_signal(5, SIGKILL, NULL, 0) = 0 [pid 816007] waitid(P_PIDFD, 5, <unfinished ...> [pid 816009] +++ killed by SIGKILL +++ [pid 816007] <... waitid resumed>{si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=816009, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=0}, WEXITED, NULL) = 0 [pid 816007] --- SIGCHLD {si_signo=SIGCHLD, si_code=CLD_KILLED, si_pid=816009, si_uid=1001, si_status=SIGKILL, si_utime=0, si_stime=0} --- [pid 816007] +++ exited with 0 +++ ```
workingjubilee
added a commit
to workingjubilee/rustc
that referenced
this pull request
Jun 21, 2024
Add PidFd::{kill, wait, try_wait} rust-lang#117957 changed `Child` kill/wait/try_wait to use its pidfd instead of the pid, when one is available. This PR extracts those implementations and makes them available on `PidFd` directly. The `PidFd` implementations differ significantly from the corresponding `Child` methods: * the methods can be called after the child has been reaped, which will result in an error but will be safe. This state is not observable in `Child` unless something stole the zombie child * the `ExitStatus` is not kept, meaning that only the first time a wait succeeds it will be returned * `wait` does not close stdin * `wait` only requires `&self` instead of `&mut self` since there is no state to maintain and subsequent calls are safe Tracking issue: rust-lang#82971
matthiaskrgr
added a commit
to matthiaskrgr/rust
that referenced
this pull request
Jun 21, 2024
Add PidFd::{kill, wait, try_wait} rust-lang#117957 changed `Child` kill/wait/try_wait to use its pidfd instead of the pid, when one is available. This PR extracts those implementations and makes them available on `PidFd` directly. The `PidFd` implementations differ significantly from the corresponding `Child` methods: * the methods can be called after the child has been reaped, which will result in an error but will be safe. This state is not observable in `Child` unless something stole the zombie child * the `ExitStatus` is not kept, meaning that only the first time a wait succeeds it will be returned * `wait` does not close stdin * `wait` only requires `&self` instead of `&mut self` since there is no state to maintain and subsequent calls are safe Tracking issue: rust-lang#82971
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jun 21, 2024
Add PidFd::{kill, wait, try_wait} rust-lang#117957 changed `Child` kill/wait/try_wait to use its pidfd instead of the pid, when one is available. This PR extracts those implementations and makes them available on `PidFd` directly. The `PidFd` implementations differ significantly from the corresponding `Child` methods: * the methods can be called after the child has been reaped, which will result in an error but will be safe. This state is not observable in `Child` unless something stole the zombie child * the `ExitStatus` is not kept, meaning that only the first time a wait succeeds it will be returned * `wait` does not close stdin * `wait` only requires `&self` instead of `&mut self` since there is no state to maintain and subsequent calls are safe Tracking issue: rust-lang#82971
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Jun 22, 2024
Add PidFd::{kill, wait, try_wait} rust-lang#117957 changed `Child` kill/wait/try_wait to use its pidfd instead of the pid, when one is available. This PR extracts those implementations and makes them available on `PidFd` directly. The `PidFd` implementations differ significantly from the corresponding `Child` methods: * the methods can be called after the child has been reaped, which will result in an error but will be safe. This state is not observable in `Child` unless something stole the zombie child * the `ExitStatus` is not kept, meaning that only the first time a wait succeeds it will be returned * `wait` does not close stdin * `wait` only requires `&self` instead of `&mut self` since there is no state to maintain and subsequent calls are safe Tracking issue: rust-lang#82971
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
O-linux
Operating system: Linux
O-unix
Operating system: Unix-like
S-waiting-on-bors
Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
T-libs
Relevant to the library team, which will review and decide on the PR/issue.
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.
This should get us closer to stabilization of pidfds since they now do something useful. And they're
CLOEXEC
now.