Comments (12)
Is the command you would like to run well-known, or is it proprietary? I would be helpful to see an example, since the solution is probably dependant on specific behaviors of the utility you're running.
from entr.
It's an open-source command called fly. When I run fly set-pipeline
it prompts me to say yes when there are changes. I don't want to just apply those changes every time, but it is helpful to see them. If I made another change to the watched file, I'd like for the fly set-pipeline
process to be killed and restarted. If I use -r
it can't accept my confirmation. If I don't use -r
then it doesn't get killed if I make two separate changes so it'd only show the results from the first change.
from entr.
Looking at https://github.com/concourse/concourse/blob/master/fly/commands/set_pipeline.go it seems that -n
can be used to skip the confirmation prompt. See if this works.
entr -r
can't support this directly since the utility is run as a background task. On Unix-like systems background tasks are halted if they try to read from STDIN
(To guard against this, entr
closes STDIN
when -r
is used.)
If this doesn't work, we could run the command in a disconnected tmux session, but that would be a nussance.
from entr.
It works as expected when run without -r
; i.e. I'm able to interact with the command when required. How is the handling of the non--r
case different?
from entr.
I am aware of -n
btw; I didn't want to use that since setting a pipeline is a dangerous operation to run without a prompt so I do want to confirm before going ahead.
from entr.
Try running this:
fly set-pipeline &
You should see the process state T
meaning it was suspended for terminal interaction. Similarly, with -r
entr is running the utility as a background process so that it can respond to input (keyboard, file system events) even if the child process is still running.
from entr.
Thanks -- I understand the part about how running it in the background works. My question is more about why it works when I run entr
without -r
. Does entr
run the job in the foreground in that case? Also, why is it necessary to run the task in the background when using -r
?
from entr.
There are a couple things going on: without -r
entr waits for the child process to end with waitpid(2)
. We understand that part.
With -r
both the parent (entr) and the child (your utility) would read input from the same terminal. This would result in undefined behavior, and closing stdin on the child allows entr to accept keyboard input (q
, <space>
, Ctrl-C
).
The second sticking point is that in restart mode entr needs signals to propagate. This mechanism is used to make the child the leader of it's own process group
if (restart_opt == 1) {
setpgid(0, getpid());
}
Now when entr sends SIGTERM the utility and all of it's subprocess receive the signal. But setting a new process group is also what prevents the child from reading STDIN. If it does, the kernel will suspend it. Finding your process in the T
state is confusing, so entr closes STDIN to raise an error instead.
from entr.
Got it -- thank you for taking the time to explain. It does sound like this would not work the way I'm imagining. I guess I'll just deal with having to confirm every time for now. Great utility, btw -- I've found it to be flexible and useful for a wide variety of use cases.
from entr.
Thanks for the kind words @jaresty! After working through this ticket I realized how difficult it is to see why the -r
can't be used with an interactive task. I added a section
http://eradman.com/entrproject/ called Other Implementation Details which should help others who are trying to understand this behavior.
from entr.
Thanks -- I read through the new docs section and it makes sense.
from entr.
Does that mean it's impossible to have -r
work with interactive commands? I wanted to do something like echo filename | entr -r less /_
If entr
didn't consume from stdin, and instead got the filenames from somewhere else, could this be doable?
This project is great and interactive usage is the only thing that isn't achievable at the moment. Even then, it's too handy. Thank you anyway
from entr.
Related Issues (20)
- entr is running twice HOT 5
- Tests are failing on archlinux HOT 3
- Minor doc proposal: A sentence to be explicit about some uses of '-s' HOT 2
- Error when running make install ../data.h: No such file or directory HOT 4
- File changes not detected in a certain condition HOT 5
- How to deal with user input? HOT 8
- `-r` option seems to force reboot on MacOS HOT 6
- entr: No regular files to watch in ruby HOT 8
- Alternatives to SIGTERM with -r HOT 11
- Use strlcpy with >=glibc-2.38 HOT 9
- Missing entr command on website HOT 1
- Ability to kill the process after a timeout if it fails to stop gracefully HOT 7
- `/_` marker and quotes. HOT 2
- doesn't this force the RLIMIT_NOFILES to be exactly 65536? HOT 11
- Feature request: provide a way to debounce triggers HOT 8
- fatal error: sys/sysctl.h: No such file or directory HOT 3
- `entr` apparently don't work when called from a Makefile task HOT 3
- Only the first event is handled when using entr to watch the script that runs entr HOT 9
- $0 isn't populated on macOS when using -s HOT 5
- Git tags are not signed HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from entr.