Skip to content
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

Windows support? #12

Open
hmaarrfk opened this issue Jan 17, 2018 · 8 comments · May be fixed by #63
Open

Windows support? #12

hmaarrfk opened this issue Jan 17, 2018 · 8 comments · May be fixed by #63

Comments

@hmaarrfk
Copy link

Any possibility of this working with windows?

it seems the two commands are the only ones that are windows specific, but I could be wrong

flags = fcntl(pipe_out, F_GETFL)
fcntl(pipe_out, F_SETFL, flags|os.O_NONBLOCK)
@minrk
Copy link
Owner

minrk commented Jan 22, 2018

I'm not opposed to Windows support, but I have no idea how to do it. I thought all of the dup2, pipe stuff didn't work on Windows, but looking at the Python docs, they may, so it could be relatively easy. If you'd like to explore adding Windows support, that would be great!

@chrisjbillington
Copy link

chrisjbillington commented Mar 26, 2018

You might be interested in some code of mine that does a similar thing and works on Windows, to see how this might be done. I'm not totally happy with it, since there is the possibility of C output coming out in the wrong order compared to Python output, but it mostly works.

It's difficult to do it in a foolproof way because Windows doesn't support select(), so you have to have separate threads reading the pipes for each stream, leading to a higher probability of stdout and stderr coming out in the wrong order depending on thread scheduling. A similar problem exists when using select() as far as I can tell (multiple writes to stdout could be read in one go even though there should be a line of stderr in between), but had a lower probability of actually resulting in wrong output. I'm yet to know of a way to do output redirection in a way that can distinguish between stdout and stderr without there being some race conditions like this leading to potentially wrong output order. But if it's just for humans looking at output then it's mostly good enough.

bjodah added a commit to bjodah/staged-recipes that referenced this issue Jun 28, 2018
bjodah added a commit to bjodah/staged-recipes that referenced this issue Jun 28, 2018
bjodah added a commit to bjodah/staged-recipes that referenced this issue Jun 28, 2018
@jakirkham
Copy link
Contributor

Do you have a permalink for that @chrisjbillington? Appears the location referenced has moved.

@chrisjbillington
Copy link

@jakirkham, I don't have a permalink to a line number, but the functionality is in the OutputInterceptor and StreamProxy classes in process_tree.py of the zprocess project.

@Lothiraldan
Copy link

Does the usage now of selector2 opens up the support of Windows?

@jakirkham
Copy link
Contributor

Did you try it?

@minrk
Copy link
Owner

minrk commented Oct 23, 2021

this gist appears to work on Windows with a similar approach, so it might not be so hard.

@chrisjbillington
Copy link

For what it's worth as another reference, the project of mine that does this on Windows is still around, has moved to GitHub:

https://github.com/chrisjbillington/zprocess/blob/89b464c3a2d10cb3282bea625670f807430adf03/zprocess/process_tree.py#L660

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

Successfully merging a pull request may close this issue.

5 participants