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

示例代码无法运行的问题 #15

Open
TaoSunkist opened this issue May 12, 2018 · 3 comments
Open

示例代码无法运行的问题 #15

TaoSunkist opened this issue May 12, 2018 · 3 comments

Comments

@TaoSunkist
Copy link

goc2p/src/multiproc/apipe/apipe.go
demo2 为何会阻塞住?

@danielsunzhongyuan
Copy link

danielsunzhongyuan commented May 14, 2018

I encountered the same problem, and here was the solution:
change the arg of "aux" to "au" or "x", both will work.

I am using Mac with OSX 10.13.4 version, zsh, Go1.8.1.

For further research, you can try:

  1. use different Go version. The first edition of this book uses Go1.3 while now the latest version of Go is 1.10
  2. OS aspects. Try Redhat / CentOS, try shell / bash, etc.

PS. here is the example code for the second edition of this book.
https://github.com/gopcp/example.v2/blob/master/src/gopcp.v2/chapter3/apipe/apipe.go

我跟你遇到了同样的问题,目前查到的结果是:
把第一个命令 ps 的参数从 "aux"变成 "au"或者"x"就可以了,总之 "aux"不能同时出现。
我使用的环境是:
Macbook Pro,10.13.4,zsh,Go1.8.1 

下一步的调查方向:
1. Go的版本问题。作者写第一版书的时候用的是Go1.3版本,而我用的是1.8版本,现在最新的已经有1.10了。(1.8和1.9的表现也不一样)
2. 系统方面。可以试一试原生的 bash,或者 shell,然后试一试 Linux(Redhat or CentOS)等。

此外,可以看看这本书的第二版,代码更清晰,也没有问题。
https://github.com/gopcp/example.v2/blob/master/src/gopcp.v2/chapter3/apipe/apipe.go

@danielsunzhongyuan
Copy link

danielsunzhongyuan commented May 14, 2018

还有啊:
用 IDE(Gogland)去 Run 'go build apipe.go' 是不行的。但是直接用命令行 go run apipe.go 是可以的,而且,用命令行 go build apipe.go && ./apipe 也是可以的。

@sunlianqiang
Copy link

今天看到这遇到了相同的问题,是代码有bug,在cmd2 start之前就向cmd2的stdin中写数据,数据无法被处理导致程序阻塞。
修改很简单,就是把写数据操作放在cmd2 start之后,已经提交了pull request #19

met the same problem today.
It outcomes a bug of the code. Because outputBuf1.WriteTo(stdin2) write output of command1 before commond2 start, and that will make the process block.
You can see the change from my pull request, #19

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

3 participants