question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

elm-watch doesn't exit when stdin closes

See original GitHub issue

In my use case I spawn elm-watch hot from my backend app which uses Phoenix. I configure Phoenix using a watcher (https://hexdocs.pm/phoenix/Phoenix.Endpoint.html#module-runtime-configuration). I am also spawning esbuild for my other assets in the same way.

When Phoenix exits it signals to the child processes (esbuild and elm-watch in my case) that they should also exit by closing stdin, however, elm-watch doesn’t exit and is thus left running, so needs to be killed manually.

This is easy to reproduce by running npx elm-watch hot and then pressing ctrl-d - this closes stdin but has no effect on elm-watch which continues running.

I think this should be the standard behaviour for tools like this as both esbuild and webpack terminate from their “watch” mode when stdin is closed.

I can work around this by wrapping elm-watch in this script but it would be nice if this was handled directly by elm-watch.

I tried to fix this, but my JS/Node knowledge is quite basic and I wasn’t able to find the right place in the code to listen for stdin being closed and exit so unfortunately I cannot offer a PR.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

2reactions
lydellcommented, Oct 23, 2022

Fixed the regression, released 1.1.0-beta.5 with this change. Hoping to release 1.1.0 the coming week.

1reaction
lydellcommented, Oct 22, 2022

A new version coming soon! At least a beta. I was going to release it as non-beta, but found a (minor) regression.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Process not closing when stdin is closed - Unix Stack Exchange
Once echo has written "foo\n" , it exits which causes the writing end of the pipe to be closed, then the read() done...
Read more >
Are stdin/stderr guaranteed to be closed after process ...
In other words, yes, it can happen that the child terminates but the parent does not see the pipe close. Also, it is...
Read more >
How do I close stdin in a shell script? - Super User
Is there a way to close stdin? ... n<&- Close input file descriptor n. ... An example program that you would expect to...
Read more >
Close Files And Pipes (The GNU Awk User's Guide)
The file or pipe stays open until awk exits. This implies that special steps are necessary in order to read the same file...
Read more >
linux - Can I send some text to the STDIN of an active process ...
First create a named pipe to route STDIN through: mkfifo /data/in . Then block it for writing, so it does not get closed...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found