Unsubscribe

2020-08-04 Thread a.e.handy

Good bye "a.e.handy"  :-(
You are now unsubscribed




--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe



Subscribe

2020-08-04 Thread silas poulson
Hello silas poulson  :-)
You are now subscribed



--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: Issue with pipe and file descriptors

2020-08-04 Thread Davide BERTOLOTTO
Thanks a lot Alex, with the "wait" is working fine!

Cheers,
Davide

On Tue, Aug 4, 2020, 16:42 Alexander Burger  wrote:

> Hi Davide,
>
> > I have encountered a strange behavior while running some pipes (the
> number
> > of "do" iterations may require some adjustment to trigger the effect):
> > (do 1 (pipe (prin "A string") (make (while (rd 1) (link @)
> >
> > The execution stops with an error like this (the actual number may vary)
> > ? 1345 FD too high
> >
> > In Termux this happened with something as low as 300. Note also that in
> > Termux I have a pretty high number of files that can be open at the same
> > time (~65K).
> >
> > I would expect that the file descriptors are closed after the pipe
> > execution.
>
> This is correct, but it takes a while. After the pipe'd child process
> terminated, the Linux kernel sends a SIGCHLD signal to the parent process,
> which
> then does a waitpid() system call in the signal handler.
>
> So it is necessary not to create too many child processes at the same
> time. The
> above should work if you add a short delay, e.g.
>
>(do 1
>   (pipe (prin "A string")
>  (make (while (rd 1) (link @))) )
>   (wait 10) )
>
> ☺/ A!ex
>
> --
> UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe
>


Re: Issue with pipe and file descriptors

2020-08-04 Thread Alexander Burger
Hi Davide,

> I have encountered a strange behavior while running some pipes (the number
> of "do" iterations may require some adjustment to trigger the effect):
> (do 1 (pipe (prin "A string") (make (while (rd 1) (link @)
> 
> The execution stops with an error like this (the actual number may vary)
> ? 1345 FD too high
> 
> In Termux this happened with something as low as 300. Note also that in
> Termux I have a pretty high number of files that can be open at the same
> time (~65K).
> 
> I would expect that the file descriptors are closed after the pipe
> execution.

This is correct, but it takes a while. After the pipe'd child process
terminated, the Linux kernel sends a SIGCHLD signal to the parent process, which
then does a waitpid() system call in the signal handler.

So it is necessary not to create too many child processes at the same time. The
above should work if you add a short delay, e.g.

   (do 1
  (pipe (prin "A string")
 (make (while (rd 1) (link @))) )
  (wait 10) )

☺/ A!ex

-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Issue with pipe and file descriptors

2020-08-04 Thread Davide BERTOLOTTO
Hi all,

I have encountered a strange behavior while running some pipes (the number
of "do" iterations may require some adjustment to trigger the effect):
(do 1 (pipe (prin "A string") (make (while (rd 1) (link @)

The execution stops with an error like this (the actual number may vary)
? 1345 FD too high

In Termux this happened with something as low as 300. Note also that in
Termux I have a pretty high number of files that can be open at the same
time (~65K).

I would expect that the file descriptors are closed after the pipe
execution. I tested it and it seems that if one prints the (fd) at every
loop it is always the same number.
Why is this happening? It looks like the actual FD number in the underlying
system is too big...

Regards,
Davide