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

peco.Cancel action #107

Closed
syohex opened this issue Jun 29, 2014 · 16 comments
Closed

peco.Cancel action #107

syohex opened this issue Jun 29, 2014 · 16 comments

Comments

@syohex
Copy link
Contributor

syohex commented Jun 29, 2014

I suppose peco.Cancel should work like sending SIGINT.
(peco.Cancel should kills processes in same session group.)
Now successive command is executed if peco.Cancel is executed.
For example,

% ls -l | peco | xargs echo "hoge"
hoge

On the other hand, cancel command of percol(C-c) works like sending SIGINT.

% ls -l |percol| xargs echo "hoge"
# Nothing is shown
@lestrrat
Copy link
Contributor

In that respect, peco's SIGINT handling is also broken. Yeah, time to fix it. :)

@lestrrat
Copy link
Contributor

あれ、EscおしてCancelさせたらちゃんと1でexitした。SIGINTは壊れてた。
最新版でもそうなります?

@syohex
Copy link
Contributor Author

syohex commented Jun 29, 2014

はい, そうなります. pecoがパイプでつないだコマンド群の最後だと
いいんですが, 途中にあると後続のコマンドが実行されてしまうので,
望まれるものと違うのではないかと思っています.

パイプの途中が exit status=0以外でも後続のコマンドは実行されて
しまいますので, 今は peco.Cancelをした場合, 以下のようになって
いるだけだと思います.

% ls -l |false|xargs echo hoge

@lestrrat
Copy link
Contributor

いや、Esc押すと実行されないんだけどな…
107

@syohex
Copy link
Contributor Author

syohex commented Jun 29, 2014

私の環境の問題ですかね ?

手元にある Linuxだと全部後続のコマンドが実行されてしまっています.
Macでも試してみます.

@lestrrat
Copy link
Contributor

OSごとに違ってたらいやだなー

@syohex
Copy link
Contributor Author

syohex commented Jun 29, 2014

Macで確認しましたが, Macだと後続のコマンドが実行されませんでした
(全く同じ zshの設定ファイルでそうなりました) bashでも Macと Linuxで同様の違いが
見られたので, OSの違いからくる挙動の違いのように思えます.

@syohex
Copy link
Contributor Author

syohex commented Jun 29, 2014

OSの差ではなく, xargsの挙動の違いでした.
BSD系のユーザランドの xargs(Mac, *BSD)は入力がないとコマンドを
実行しないようです. 一方 findutilsの xargsは入力がなくてもコマンドを
実行してしまうようです.

Macだと

% echo | xargs ls

は何も出力しませんが, findutils(Linux)だと lsの結果が出力されます.
findutils版 xargsだと -rをつけると BSD版と同じ挙動になるようです.

@lestrrat
Copy link
Contributor

すみません、子供と寝落ちしてました。ちょっと今日その辺り見ますね。

@lestrrat
Copy link
Contributor

結局のところxargsはexit値がnon-zeroでもうごいちゃうってことなのかなー。
とりあえず僕の環境ではこう。

shoebill% ps | ./peco | echo $?   <---- Esc
1
shoebill% ps | ./peco | echo $?   <---- SIGINT
0

で、SIGINTとEscをまずそろえるべきだと思うので、これは直しましょう。

Linuxの場合にパイプが途中で切れないっていうのは結局pecoの問題ではないということでいいんですかね。ちょっと混乱してますが。

lestrrat added a commit that referenced this issue Jun 29, 2014
@lestrrat
Copy link
Contributor

とりあえず 9fcce5c でSIGTERM/INTはこうなる

shoebill% ps | ./peco ; echo $?
1

@lestrrat
Copy link
Contributor

とりあえず @syohex さん待ち。

@syohex
Copy link
Contributor Author

syohex commented Jun 29, 2014

Linuxの場合にパイプが途中で切れないっていうのは結局pecoの問題ではないということでいいんですかね。ちょっと混乱してますが。

はい, そう見えるのは pecoの問題ではないです.
実際には Macでも Linuxでもパイプが途中で切れるということは起きていなくて,
上述の, xargsの挙動の違いにより, パイプが切れたように見えるということになります.

@lestrrat
Copy link
Contributor

はーい。ではとりあえずシグナルを直したのでマージしますね。

@lestrrat
Copy link
Contributor

んで、とりあえずクローズします。やっぱりまだなんかおかしい場合は新規にお願いします。

@syohex
Copy link
Contributor Author

syohex commented Jun 30, 2014

了解です. 期待することの実現方法がそもそもわからないので,
実現可能なのかというところから検証していきます.

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

2 participants