Re: too many open files?

2012-09-06 Thread Alexander Burger
Hi José,

> Why not just:
> 
> (in (list "stat" "-c" "(`(hex \"%f\") %s %u %g %h %i %X %Y %Z)" Path)
>(read) ) 

Nice! Very clever! (PicoLisp-ish ;)

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


Re: too many open files?

2012-09-06 Thread Laurent Artaud

Le 06/09/2012 08:50, José Romero a écrit :


Why not just:

(in (list "stat" "-c" "(`(hex \"%f\") %s %u %g %h %i %X %Y %Z)" Path)
(read) )

:D



Wow!

It took me at least ten minutes to realize WHY it was working!
I can honestly say that I would have NEVER thought to use stat's output 
formating option to this end!


I'm not worthy (yet?)

Thanks for sharing this!

Regards,
--
Laurent ARTAUD (laurent.art...@free.fr)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: too many open files?

2012-09-06 Thread Laurent Artaud

Le 06/09/2012 08:01, Alexander Burger a écrit :

Hi Laurent,

back to your original mail:


By the way, if anyone know what lib to use for (native) to make a
lstat syscall so I can replace the stat shell call, I'd be very
grateful: I can't find where it is! (contrary to what I thought, it
is NOT in libc...)


It seems the internal symbol is '__xstat'.


From "/usr/include/x86_64-linux-gnu/sys/stat.h":


__extern_inline int
__NTH (stat (__const char *__path, struct stat *__statbuf))
{
  return __xstat (_STAT_VER, __path, __statbuf);
}

That's a pity, because it makes it rather unportable.




So... If I need more speed, I'll have to make a C lib calling lstat, then call 
this one with (native)... I think I'll stay with the shell call ;-)




BTW, instead of using 'line', 'split' and 'pack' in


(de stat (Path)
(mapcar pack
   (split
  (in
 (list "stat" "-c" "%f %s %u %g %h %i %X %Y %Z" Path)
 (line) )
  " " ) ) )


and later parsing it with 'hex' and 'format', you could read it
directly:

(in (list "stat" "-c" "%f %s %u %g %h %i %X %Y %Z" Path)
(make
   (link (hex (till " "))
   (do 8
  (link (read)) ) ) ) )



Thanks for this! I intended to replace the call to (multimap) when I discovered 
that I had only one (hex) to call...


Regards,
--
Laurent ARTAUD (laurent.art...@free.fr)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: too many open files?

2012-09-06 Thread Laurent Artaud

Le 05/09/2012 19:20, Alexander Burger a écrit :

On Wed, Sep 05, 2012 at 09:34:10AM +0200, Alexander Burger wrote:

I don't have the time at the moment to investigate it further. I hope I
can fix it this evening.


We need just to insert a call to closedir(). I've uploaded a fix to the
code repository.

As I'm in the process of other changes, I don't want to provide a new
testing release at the moment. If you need a quick fix, please insert a
single line in "src64/main.l" and re-assemble the binary:

2922a2923
>  cc closedir(Z)  # Close directory


I.e. the context is

   do
  cc readdir(Z)  # Find first directory entry
  null A  # OK?
  if z  # No
 cc closedir(Z)  # Close directory  <-- NEW
10   ld E Nil  # Return NIL
 pop Z
 pop X
 ret
  end
  lea E (A D_NAME)  # Pointer to name entry
  cmp X Nil  # flg?
   while eq  # Yes

Cheers,
- Alex



Thanks for the quick fix!

--
Laurent ARTAUD (laurent.art...@free.fr)
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: too many open files?

2012-09-05 Thread José Romero
On Thu, 6 Sep 2012 08:01:28 +0200
Alexander Burger  wrote:

> Hi Laurent,
> 
> back to your original mail:
> 
> > By the way, if anyone know what lib to use for (native) to make a
> > lstat syscall so I can replace the stat shell call, I'd be very
> > grateful: I can't find where it is! (contrary to what I thought, it
> > is NOT in libc...)
> 
> It seems the internal symbol is '__xstat'.
> 
> >From "/usr/include/x86_64-linux-gnu/sys/stat.h":
> 
>__extern_inline int
>__NTH (stat (__const char *__path, struct stat *__statbuf))
>{
>  return __xstat (_STAT_VER, __path, __statbuf);
>}
> 
> That's a pity, because it makes it rather unportable.
> 
> 
> 
> BTW, instead of using 'line', 'split' and 'pack' in
> 
> > (de stat (Path)
> >(mapcar pack
> >   (split
> >  (in
> > (list "stat" "-c" "%f %s %u %g %h %i %X %Y %Z" Path)
> > (line) )
> >  " " ) ) )
> 
> and later parsing it with 'hex' and 'format', you could read it
> directly:
> 
> (in (list "stat" "-c" "%f %s %u %g %h %i %X %Y %Z" Path)
>(make
>   (link (hex (till " "))
>   (do 8
>  (link (read)) ) ) ) ) 
> 
Why not just:

(in (list "stat" "-c" "(`(hex \"%f\") %s %u %g %h %i %X %Y %Z)" Path)
   (read) ) 

:D

> Cheers,
> - Alex

Cheers,
- José
--
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: too many open files?

2012-09-05 Thread Alexander Burger
Hi Laurent,

back to your original mail:

> By the way, if anyone know what lib to use for (native) to make a
> lstat syscall so I can replace the stat shell call, I'd be very
> grateful: I can't find where it is! (contrary to what I thought, it
> is NOT in libc...)

It seems the internal symbol is '__xstat'.

>From "/usr/include/x86_64-linux-gnu/sys/stat.h":

   __extern_inline int
   __NTH (stat (__const char *__path, struct stat *__statbuf))
   {
 return __xstat (_STAT_VER, __path, __statbuf);
   }

That's a pity, because it makes it rather unportable.



BTW, instead of using 'line', 'split' and 'pack' in

> (de stat (Path)
>(mapcar pack
>   (split
>  (in
> (list "stat" "-c" "%f %s %u %g %h %i %X %Y %Z" Path)
> (line) )
>  " " ) ) )

and later parsing it with 'hex' and 'format', you could read it
directly:

(in (list "stat" "-c" "%f %s %u %g %h %i %X %Y %Z" Path)
   (make
  (link (hex (till " "))
  (do 8
 (link (read)) ) ) ) ) 

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


Re: too many open files?

2012-09-05 Thread Alexander Burger
On Wed, Sep 05, 2012 at 09:34:10AM +0200, Alexander Burger wrote:
> I don't have the time at the moment to investigate it further. I hope I
> can fix it this evening.

We need just to insert a call to closedir(). I've uploaded a fix to the
code repository.

As I'm in the process of other changes, I don't want to provide a new
testing release at the moment. If you need a quick fix, please insert a
single line in "src64/main.l" and re-assemble the binary:

   2922a2923
   >  cc closedir(Z)  # Close directory


I.e. the context is

  do
 cc readdir(Z)  # Find first directory entry
 null A  # OK?
 if z  # No
cc closedir(Z)  # Close directory  <-- NEW
   10   ld E Nil  # Return NIL
pop Z
pop X
ret
 end
 lea E (A D_NAME)  # Pointer to name entry
 cmp X Nil  # flg?
  while eq  # Yes

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


Fast vendor response time (Was: Re: too many open files?)

2012-09-05 Thread Jakob Eriksson


Talk about fast vendor response time!



On September 5, 2012 at 9:34 AM Alexander Burger  wrote:

> Opps, I can reproduce it! And I found this is a bug in the 'dir'
-- 
UNSUBSCRIBE: mailto:picolisp@software-lab.de?subject=Unsubscribe


Re: too many open files?

2012-09-05 Thread Alexander Burger
Hi Laurent,

> Pipe error: Too many open files

Opps, I can reproduce it! And I found this is a bug in the 'dir'
function on pil64. It leaks file descriptors _if_ the directory is
empty:

   $ mkdir a

   $ pil +
   : (call 'ls "-l" (pack "/proc/" *Pid "/fd"))
   total 0
   lrwx-- 1 app app 64 Sep  5 09:31 0 -> /dev/pts/0
   lrwx-- 1 app app 64 Sep  5 09:31 1 -> /dev/pts/0
   lrwx-- 1 app app 64 Sep  5 09:31 2 -> /dev/pts/0

   : (dir "a") 
   -> NIL

   : (call 'ls "-l" (pack "/proc/" *Pid "/fd"))
   total 0
   lrwx-- 1 app app 64 Sep  5 09:31 0 -> /dev/pts/0
   lrwx-- 1 app app 64 Sep  5 09:31 1 -> /dev/pts/0
   lrwx-- 1 app app 64 Sep  5 09:31 2 -> /dev/pts/0
   lr-x-- 1 app app 64 Sep  5 09:31 3 -> /home/app/picoLisp/a

I don't have the time at the moment to investigate it further. I hope I
can fix it this evening.

Thanks!!

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