<fuxoft>
When the external script ("ls" in this case) terminates and there are no more lines available, the (task) keeps executing and I am unable to stop it, not to mention restart it with different pipe
<abu[7]>
Hi fuxoft, 'task' usually checks for EOF (ie. NIL)
<fuxoft>
My example is simplified. In reality I am reading char-by-char and the input parsing routine is more complex. There are potentially no newlines in the stream.
<abu[7]>
"the (task) keeps executing" so there is no EOF?
<fuxoft>
Ideally there is no EOF. But I want to write it in such a way that when there the external script stops for whatever reason (e.g. crashes), it's immediately restarted.
<abu[7]>
But then the file descriptor is closed and invalid
<abu[7]>
Closing the task with (task Pipe) is good, but then you need a new task
<fuxoft>
Yep, so I want to replace the original (task) with a new (task) without FHandlerChar function even noticing that something happened
<fuxoft>
That's why I am trying to call (commandReader) again at the end of the task (when the pipe closes)
<abu[7]>
(commandReader) does not create a new task
<abu[7]>
wait
<fuxoft>
It should
<abu[7]>
yeah
<fuxoft>
Oops, the "(when *PPid..." line should not be there, I forgot to remove it when creating the minimal example
<abu[7]>
what confuses me is the (while (line) .. Is (run FDisconnect) ever reached?
<abu[7]>
That's only a log
<fuxoft>
Yep. When ls finishes, (line T) returns NIL, doesn't it?
<abu[7]>
Yep
<abu[7]>
btw, i ran it and it seems to work fine
<fuxoft>
Wait, it runs fine on your machine, e.g. produces the output of ls repeatedly endlessly?
<abu[7]>
it closes and restarts '(ls ".")
<abu[7]>
Yes
<abu[7]>
Many ("Got:"...")
<fuxoft>
On my machine, it starts failing with "Pipe error: Too many open files" after a while
<abu[7]>
the exactly same script?
<fuxoft>
Wait a moment, I will check again.
<abu[7]>
Only (commandReader ..) starts the pipe
<fuxoft>
Yes.
<abu[7]>
and it should not be called before the first pipe closed
<abu[7]>
looks all right
<fuxoft>
At first it runs OK for a while, then it starts signalling "Pipe was closed" without reading any lines, and after some more iterations it starts failing with "Pipe error: Too many open files"
<abu[7]>
I try a longer run
<abu[7]>
Still running, but seems to get slower
<fuxoft>
No, sorry, the "Too many open files" error starts appearing first but otherwise it still produces the correct output.
<fuxoft>
My pil version is (24 6 27)
<abu[7]>
ok
<abu[7]>
Seems I don't get that error
<abu[7]>
(on Termux)
<abu[7]>
Is it from (pipe)?
<fuxoft>
BTW it behaves the same way both on my desktop PC (Ubuntu) and in Linux containter on Chromebook