-
Notifications
You must be signed in to change notification settings - Fork 7.7k
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
Fix pcntl get/set priority #9044
Conversation
(is really hard to test it before pushing when you don't have a Mac) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the PR! I'll try to do a full review tomorrow, but left some comments for things that caught my attention while skimming over the patch.
ext/pcntl/pcntl.c
Outdated
@@ -1274,8 +1275,22 @@ PHP_FUNCTION(pcntl_getpriority) | |||
php_error_docref(NULL, E_WARNING, "Error %d: No process was located using the given parameters", errno); | |||
break; | |||
case EINVAL: | |||
#ifdef PRIO_DARWIN_BG |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Preprocessor directives should always start at the beginning of a line (there may be whitespace between the #
and the symbol, but in this case this would not be helpful:
#ifdef PRIO_DARWIN_BG | |
#ifdef PRIO_DARWIN_BG |
Same for the other new directives in this file.
Thanks @cmb69 a lot! I will wait for your full review before I do the suggested changes (so the pipeline does not have to run again) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The logic makes sense to me. Just those small NITs from @cmb69 .
Thanks for the review; and yes, I will apply the NITs from @cmb69 after the full review. PD: I dont know what is better for you people, if
I do whatever is better for the process |
I just did the full review ;) |
There's not that much to review though excepting checking the docs and logic. |
Please fix those NITs, squash it to a single commit and push force it here. |
5ae27f7
to
01b698e
Compare
01b698e
to
55d165e
Compare
That Travis CI failure is intermittent, so not related to this PR. Thank you for the patch! |
Code
Extension: pcntl
Functions:
pcntl_setpriority()
,pcntl_getpriority()
The problem
The PHP code to handle the errors for the mentioned functions is Linux aware only. Mac OS has a different behavior and uses the same error code for different things; plus FreeBSD does not respond in the same way as Linux or Mac under certain circumstances.
Because this feature (managing processes) is very OS dependent we cannot fully test the whole code, and also we cannot manage it in a uniform way (one code for all of them).
Documentation per OS related to possible error codes that can be return for the getpriority() and setpriority() functions
Errors per OS:
Mac
FreeBSD
Linux
The PHP code at the moment (master)
pcntl_getpriority()
pcntl_setpriority()
So as we can see the code to manage the errors is wrong as it will work as expected in Linux and FreeBSD, but not in MacOS.
This change pretends to fix this issue.
Relates to (already closed):
#8994
#8993
This is the first time I do such a change, please keep that in mind and advise me about anything that should be change, delete, adjust, etc.
Thanks in advance to all reviewers.
@cmb69 as promised ... here it is.