Skip to content

Extend pcntl_waitid with rusage parameter #15921

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
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

vrza
Copy link
Contributor

@vrza vrza commented Sep 16, 2024

Enhancement to #14616.

This functionality is not part of the POSIX waitid interface.

  • On FreeBSD, the wait6 system call provides it
  • On Linux, the raw waitid system call provides it, but it is not part of the interface exposed by glibc.

Conceptually, this is similar to how pcntl_wait and pcntl_waitpid extend the POSIX interface to fetch rusage info, where supported by the host OS.

Requesting code review @devnexen @bukka @petk @kocsismate @Girgias

Documentation PR for pcntl_waitid is not merged yet, I can add to that open PR, or document this in a separate one, depending on what PR we merge first.

[edit] Created a documentation PR.

@devnexen
Copy link
Member

Documentation PR for pcntl_waitid is not merged yet, I can add to that open PR, or document this in a separate one, depending on what PR we merge first.

IMHO, I would not worry that much about it. This PR qualifies more for the next major release. Ideally, the existing PR doc should be merged during the 8.4 doc rollercoaster. Merging this PR later and adding relevant infos in the doc.

@vrza vrza force-pushed the waitid-rusage branch 2 times, most recently from 9c27dde to 2254c05 Compare September 16, 2024 22:21
@vrza
Copy link
Contributor Author

vrza commented Sep 16, 2024

This PR qualifies more for the next major release.

That's fine, as this extension is fully backwards compatible with existing code.

Ideally, the existing PR doc should be merged during the 8.4 doc rollercoaster.

Cool, all comments in that doc PR have been addressed and it's ready for another round of review.

@devnexen
Copy link
Member

The FreeBSD test pass for me locally otherwise.

@vrza
Copy link
Contributor Author

vrza commented Sep 17, 2024

They pass for me locally as well. Is there an easy way to see test logs from the Cirrus CI run?

@vrza
Copy link
Contributor Author

vrza commented Sep 17, 2024

Changed unit test code to synchronize parent and child on every step.

@vrza vrza force-pushed the waitid-rusage branch 5 times, most recently from f515815 to 6166f2c Compare September 18, 2024 09:54
@vrza
Copy link
Contributor Author

vrza commented Sep 18, 2024

Found a rare race condition in the unit test, where the child could receive a signal just after signal_dispatch, but just before sleep, in which case the signal would would not interrupt the sleep, and the test would take a long time to complete. Most direct solution I could think of was replacing this code with a quick (starting at 100 ns) exponential backoff loop, so that the race condtion is neutralized, but the unit test should still complete in milliseconds.

@devnexen are you able to run that FreeBSD CI workflow again?

@devnexen
Copy link
Member

Yes the test works for me locally.

@vrza
Copy link
Contributor Author

vrza commented Sep 18, 2024

@devnexen Okay, great.

I also had a colleague test it on macOS, macOS provides (undocumented) POSIX-compatible waitid, but doesn't support rusage (tested raw syscall), so the check for wait6 syscall or Linux raw waitid syscall seems apt.

I self-reviewed one more time, and it looks good to go, but let's let others take a look as well. //cc @bukka @kocsismate

This functionality is not part of the POSIX interface.

- On FreeBSD, the wait6 system call provides it
- On Linux, the raw waitid system call provides it (glibc does not)
@bukka
Copy link
Member

bukka commented Sep 22, 2024

I will take a proper look later. It's too late for PHP 8.4 so this should wait after branching it out anyway.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants