Skip to content

Throw LogicException on Windows #47

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

Conversation

WyriHaximus
Copy link
Member

Since pipes Windows always block this PR introduces always throwing an exception so we don't allocate unnecessary resources.

Follows up #41

README.md Outdated
does work on [`Windows Subsystem for Linux`](https://en.wikipedia.org/wiki/Windows_Subsystem_for_Linux)
Due to the blocking nature of `STDIN`/`STDOUT`/`STDERR` pipes on Windows we can
not guarantee this package works as expected on Windows directly. As such when
instantiating `Process` it throws an exception when on Windows directly.
Copy link
Member

Choose a reason for hiding this comment

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

The doubling of "directly" at the end of the 2 sentences could probably be avoided.

src/Process.php Outdated
* @throws RuntimeException When proc_open() is not installed
*/
public function __construct($cmd, $cwd = null, array $env = null, array $options = array())
{
if (substr(strtolower(PHP_OS), 0, 3) === 'win') {
throw new \LogicException('Windows isn\'t supported.');
Copy link
Member

Choose a reason for hiding this comment

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

The exception message could be a little bit more descriptiove, something like "Windows isn't supported due to the blocking nature of STDIN/STDOUT/STDERR pipes."

@WyriHaximus WyriHaximus force-pushed the throw-exception-on-windows branch from d511846 to 3df3f54 Compare August 9, 2017 20:05
@WyriHaximus
Copy link
Member Author

@jsor updated the PR with your suggestions 👍

* @throws RuntimeException When proc_open() is not installed
*/
public function __construct($cmd, $cwd = null, array $env = null, array $options = array())
{
if (substr(strtolower(PHP_OS), 0, 3) === 'win') {
throw new \LogicException('Windows isn\'t supported due to the blocking nature of STDIN/STDOUT/STDERR pipes.');
Copy link
Contributor

Choose a reason for hiding this comment

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

Requiring not windows is same kind of precondition as requiring proc_open function to exists so both exceptions should be same type.
IMHO both should be LogicException.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense to me, what do you think @clue and @jsor? IMHO it should be done in a different PR though

Copy link
Member

Choose a reason for hiding this comment

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

No strong opinion here, but makes sense 👍

Copy link
Member Author

Choose a reason for hiding this comment

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

@mdrost care to open a PR for it?

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Member Author

Choose a reason for hiding this comment

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

@mdrost Yup saw it 👍

@WyriHaximus WyriHaximus merged commit cd4994a into reactphp:master Aug 12, 2017
@clue clue mentioned this pull request Jan 13, 2018
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
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy