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

Porcelain doesn't seem to close stdin #37

Closed
ivan opened this issue Mar 21, 2017 · 3 comments
Closed

Porcelain doesn't seem to close stdin #37

ivan opened this issue Mar 21, 2017 · 3 comments

Comments

@ivan
Copy link
Contributor

ivan commented Mar 21, 2017

Maybe I'm missing something, but all of these calls hang forever here (Erlang 19.3, Elixir master, Ubuntu 16.04.2):

Porcelain.exec("cat", [], in: "")
Porcelain.exec("cat", [], in: "hello\n")
Porcelain.exec("python", ["-c", "import sys; print sys.stdin.read()"], in: "")
Porcelain.exec("python", ["-c", "import sys; print sys.stdin.read()"], in: "hello\n")

I am guessing this happens because Porcelain doesn't close stdin on the spawned process. Do I need to do something special, or is this a bug?

I am using the basic driver, not the goon driver.

@ivan
Copy link
Contributor Author

ivan commented Mar 21, 2017

Oh, maybe a duplicate of #23.

@ivan
Copy link
Contributor Author

ivan commented Mar 21, 2017

"the exec function does not work with programs that read all input until EOF before producing any output. Such programs will hang since Erlang ports don’t provide any mechanism to indicate the end of input." https://hexdocs.pm/porcelain/Porcelain.Driver.Basic.html

@ivan ivan closed this as completed Mar 21, 2017
@ivan
Copy link
Contributor Author

ivan commented Mar 21, 2017

As a workaround, I figured out that if I just needed to send a single line to a subprocess waiting for EOF, instead of doing:

Porcelain.exec("wg", ["pubkey"], in: (privkey |> Base.encode64) <> "\n")

I could do:

Porcelain.exec("bash", ["-c", "head -n 1 | wg pubkey"], in: (privkey |> Base.encode64) <> "\n")

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

No branches or pull requests

1 participant