-
Notifications
You must be signed in to change notification settings - Fork 639
refresh display on filesystem change via entr #734
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
base: master
Are you sure you want to change the base?
Conversation
bcfa241 to
9ecdaed
Compare
|
Here is approximately what would guarantee tig its own process group and ownership of the tty: FILE *tty = fopen("/dev/tty", "r+");
int tty_fd = tty ? fileno(tty) : STDIN_FILENO;
signal(SIGTTOU, SIG_IGN);
setpgid(getpid(), getpid());
tcsetpgrp(tty_fd, getpid());
signal(SIGTTOU, SIG_DFL);That would make It would be natural to approach setpgid after #725, which separates tty init somewhat from ncurses init. The advantage of |
9ecdaed to
74ae874
Compare
74ae874 to
469d504
Compare
|
@jonas did you ever look at this one? I assume that you like the idea of a separate script per #301, but am not sure you like the idea of piggybacking on In any case, though this was marked as proof-of-concept for a long time, I have also been using it without issues during that time. If you'd like to close this, I'd propose to submit a separate PR just for process-group-leader/hangup_children(). |
|
@rolandwalker To be honest I have not looked closely at it. It sounds like a great idea to have it as a separate script since the original code to check for changes is quite convoluted. |
doc/tigrc.5.adoc
Outdated
| views are refreshed periodically using 'refresh-interval'. | ||
| views are refreshed periodically using 'refresh-interval'. When set | ||
| to 'entr', views are refreshed when the external tool | ||
| entr[http://entrproject.org/] reports a relevant filesystem event. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should be
http://entrproject.org/[entr]
469d504 to
1bb46fa
Compare
|
Did you just beat me to the rebase? |
|
Yes, I tried to handle the conflict via GitHub. BTW, I want to look at this PR next. If you have time to separate out and submit a separate PR just for process-group-leader/hangup_children() that would be great. More generally, how feasible do you think it is to avoid having a watcher script at all and instead launching |
|
More than happy to spin out the process-group-leader patch. I use tig every day and owe you no end of thanks. Maybe Mainly I did this because your suggestion in #301 seemed so easy to sketch out, and then was surprised that it worked reliably. One way to get rid of the watcher script would be to have tig fork itself, and let the logic worked out in bash be implemented in C in the child fork.
|
|
OK, I will have to look closer at entr and how to change the refresh settings to work with the external script solution. |
acbcbaa to
1038aa2
Compare
|
All builds testing the installation fails. Not sure if it's the check for empty directory that fails. |
f41f3ac to
543842b
Compare
|
yes definitely I will play with it some more. |
543842b to
8993284
Compare
external utility
8993284 to
539df70
Compare
The "external script" option discussed in #301 turned out to be easy to sketch out, at least in this crude form.
Reasoning
SIGWINCH, which it catches and synthesizes into a special keystrokeKEY_RESIZE. AndSIGWINCHalready relates to redrawing the screen.Implementation
KEY_RESIZE, with a throttle in caseSIGWINCHs arrive very fast during a GUI interactionentrin the background, and forward aSIGWINCHwhen a change is seen in the filesystemTo test
set refresh-mode = entrin~/.tigrctig statussleep 3; for i in $(seq 1 100); do touch "file_${i}.txt"; sleep 1; doneBugs
io_run_bgdoes not actually run processes asynchronously, sinceio_completecallsio_done, which waits on the pid. Soentris run under control ofshwith a backgrounding&, andSIGHUPis arranged to backgrounded children atexit. This is a good principle anyway.Buthangup_children…killpgdoes not interact well with the test suite, sincemakeis actually the leader of the process group in that case. Runningmake testwill leave behind many un-HUPpedentrwatchers. They will self-clean within several seconds, at a maximum ofrestart_intervalwhich is an aggressive 30 seconds. It should be possible to callsetpgid()to maketigthe leader of the process group, but that introduces subtle problems with TTYs and also breaks tests. None of this is an issue during ordinary execution.Edit: poll throughout
restart_intervalfor tighter self-cleaning, making the shell command even more hacktackular.