Skip to content

[Process] Enhance compatiblity with --enable-sigchild #16915

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

Merged
merged 1 commit into from
Dec 10, 2015

Conversation

nicolas-grekas
Copy link
Member

Q A
Bug fix? yes
New feature? no
BC breaks? no
Deprecations? no
Tests pass? yes
Fixed tickets #16888
License MIT
Doc PR -

This is complete rewrite of the fallback --enable-sigchild handling in the Process class.
It removes most of the differences between this and a non-sigchild-enabled php.
Which means the test suite doesn't need anymore to be replayed 3 times (which is how I started this PR, looking for a way to test this component in less time).

I validated this with a locally compiled php, sigchild-enabled. Green.
Changes affect only this special-mode php.

Ping @romainneutron and @Seldaek (original writer of the sigchild support)

Submitted on 2.3 as bugfix, which it is to me.


$process->wait();
$this->assertSame($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait');
$this->assertContains($commandLine, $process->getCommandLine(), '::getCommandLine() returns the command line of PHP after wait');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why changing these conditions ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

because there are too much tightened to implementation details, and in fact do not work when testing with a sighchild enabled php

*/
public function hasBeenSignaled()
{
$this->requireProcessIsTerminated(__FUNCTION__);

if ($this->isSigchildEnabled()) {
throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we are now able to retrieve it when enhancing compat, but can we also without enhancing it ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

knowing "if" it has been signaled works with or without enhanced mode thanks to https://github.com/symfony/symfony/pull/16915/files#diff-f9f2411040cda7b73402481facf3e4ddR1133
knowing which signal is more tricky and requires enhanced mode

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in fact, I was wrong, knowing "if" it has been signaled doesn't work without the enhanced mode, fixed

@nicolas-grekas nicolas-grekas force-pushed the fixsigchild branch 2 times, most recently from 14d13ee to 7b11f1f Compare December 8, 2015 18:44
@nicolas-grekas
Copy link
Member Author

Comments addressed, ready for a second round of review :)

@Seldaek
Copy link
Member

Seldaek commented Dec 8, 2015

Sorry not able to review in depth right now but I sure hope it won't blow up anything. Then again I think sigchild usage is probably less and less of a problem the more time passes.

@nicolas-grekas nicolas-grekas force-pushed the fixsigchild branch 7 times, most recently from 8cadae4 to e36b1b4 Compare December 9, 2015 10:02
@nicolas-grekas
Copy link
Member Author

I added a special build of php with sigchild enabled on travis so that we can test, verify, prove and enforce that this really works :)
Enabled on the first deps=no line only.

throw new RuntimeException('This PHP has been compiled with --enable-sigchild. Term signal can not be retrieved.');
}

$this->updateStatus(false);
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updateStatus is already called by requireProcessIsTerminated

@nicolas-grekas nicolas-grekas force-pushed the fixsigchild branch 2 times, most recently from b2d9c18 to bd38abd Compare December 9, 2015 10:37
@@ -32,6 +33,7 @@ env:

before_install:
- if [[ "$deps" = "no" ]] && [[ "$TRAVIS_PHP_VERSION" =~ 5.[45] ]] && [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then export deps=skip; fi;
- if [[ $deps = no && $TRAVIS_PHP_VERSION = 5.3 && ! -d php-5.3.9/sapi ]]; then wget http://museum.php.net/php5/php-5.3.9.tar.bz2; tar -xjf php-5.3.9.tar.bz2; (cd php-5.3.9; ./configure --enable-sigchild --enable-pcntl; make -j2); fi;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume that the version will have to change for the 3.0 branch ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, I propose 5.5.9 there

@stof
Copy link
Member

stof commented Dec 9, 2015

@nicolas-grekas have you tried running tests when forcing the sighchild compat layer to be disabled ?

@nicolas-grekas
Copy link
Member Author

@stof yes. Nothing interesting here: tests either fail because of one of those exceptions about --enable-sigchild, or pass.

@stof
Copy link
Member

stof commented Dec 9, 2015

@nicolas-grekas but it needs to be done to ensure we don't miss some of the sigchild checks

@nicolas-grekas
Copy link
Member Author

nicolas-grekas commented Dec 9, 2015 via email

@romainneutron
Copy link
Contributor

Looks good to me

{
$process = new Process($commandline, $cwd, $env, $stdin, $timeout, $options);

if (false !== $enhance = getenv('ENHANCE_SIGCHLD')) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

aren't you missing a I in the name ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SIGCHLD is the name of the said signal, so it was intentional...

@stof
Copy link
Member

stof commented Dec 10, 2015

except for the comment I made, 👍

@nicolas-grekas nicolas-grekas merged commit e7cc4aa into symfony:2.3 Dec 10, 2015
nicolas-grekas added a commit that referenced this pull request Dec 10, 2015
…olas-grekas)

This PR was merged into the 2.3 branch.

Discussion
----------

[Process] Enhance compatiblity with --enable-sigchild

| Q             | A
| ------------- | ---
| Bug fix?      | yes
| New feature?  | no
| BC breaks?    | no
| Deprecations? | no
| Tests pass?   | yes
| Fixed tickets | #16888
| License       | MIT
| Doc PR        | -

This is complete rewrite of the fallback `--enable-sigchild` handling in the Process class.
It removes most of the differences between this and a non-sigchild-enabled php.
Which means the test suite doesn't need anymore to be replayed 3 times (which is how I started this PR, looking for a way to test this component in less time).

I validated this with a locally compiled php, sigchild-enabled. Green.
Changes affect only this special-mode php.

Ping @romainneutron and @Seldaek (original writer of the sigchild support)

Submitted on 2.3 as bugfix, which it is to me.

Commits
-------

e7cc4aa [Process] Enhance compatiblity with --enable-sigchild
@nicolas-grekas nicolas-grekas deleted the fixsigchild branch December 10, 2015 17:36

$this->commandline = '('.$this->commandline.') 3>/dev/null; code=$?; echo $code >&3; exit $code';
$this->commandline = $trap.'{ ('.$this->commandline.') <&3 3<&- 3>/dev/null & } 3<&0;';
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A comment explaining what's done in this commandline, with a link to the stackoverflow issue would be more than welcome.
I doubt anybody could read this without error in two years (thinking about the first implementation was years ago)

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.

5 participants