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

pty付きで起動したジョブが即座に終了してしまうことがある #1158

Closed
ichizok opened this issue Mar 12, 2018 · 4 comments

Comments

@ichizok
Copy link
Member

ichizok commented Mar 12, 2018

質問・報告の内容

pty: 1 かつ out_ioerr_iofile または null の設定でジョブを起動すると、ジョブが即座に終了する。

vim --clean

call term_start('sleep 10', {'out_io':'null', 'err_io':'null'})

OSの種類/ディストリ/バージョン

unix系OS

原因

channel の out と err が両方とも閉じられると、その後 in も閉じられる。
out_ioerr_iofile または null のとき、これらのfdは直接ジョブのプロセスにつながる (Vimはハンドリングしない) ので、channel の out と err はどちらも閉じられた状態で起動する。
よって、すぐ in が閉じられるが、in が pty のときは in はプロセスの制御端末であるため、閉じた時点でカーネルからプロセスにSIGHUPが送られる。

@ichizok
Copy link
Member Author

ichizok commented Mar 12, 2018

https://github.com/vim/vim/compare/master...ichizok:fix/job-on-pty.diff

isatty(in) のときには in にも channel->ch_to_be_closed |= (1 << PART_IN); をセットして閉じないようにしておき、ジョブ終了後に閉じる。
ただし、out と err が閉じられていると channel の監視が回らないため、現状 statusline を更新する契機がない。

@ichizok
Copy link
Member Author

ichizok commented Mar 21, 2018

has_pending_job() の判定内容を変更して、監視が回るようにした。
vim/vim#2734

@ichizok
Copy link
Member Author

ichizok commented Apr 6, 2018

@ichizok
Copy link
Member Author

ichizok commented Apr 26, 2018

8.0.1761
vim/vim@4e9d443

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

No branches or pull requests

1 participant