restream never shuts down on the reMarkable
When launching reStream.sh on the host, the corresponding restream process is started on the reMarkable. But when closing the window on the host, the process still runs on the remarkable. Since it has a quite high CPU load, this causes the battery of the reMarkable to deplete quickly.
I saw in the reStream.sh that it’s supposed to kill the restream process in the end, but that does not seem to happen.
So I think there are two scenarios:
reStream.shis shut down usingCtrl+Cin the terminal window. In that case, it correctly kills the process on the reMarkable.- One simply closes the ffplay windows, which also ends
reStream.sh, but in that case the process on the reMarkable is left running.
Would it be possible to detect that second case and also terminate the process?
We currently trap signals related to exiting and then kill the process running on the reMarkable: https://github.com/rien/reStream/blob/006d83e9b80fb2f3dd9db2330cce5e967d3df51a/reStream.sh#L124-L129
We are probably missing an exit signal (probably SIGPIPE or SIGCHLD), so detecting which signal it is and adding it would probably resolve the issue.
However, I also think we should be able to detect this in the process running on the reMarkable itself by looking whether the stdin and/or stdout channels are still being read from.