On Aug 6 00:24, Brian Inglis via Cygwin-apps wrote:
> On 2024-08-05 16:20, Corinna Vinschen via Cygwin-apps wrote:
> > Hi Marco,
> >
> > Achim made me aware yesterday, that less(1) shows nothing at all when
> > called on files under /proc.
> >
> > Turns out, this only works on Linux, because there's a Linux-specific
> > kludge in less, checking if a file of size 0 is on the /proc filesystem
> > and if so, handles it accordingly.
> >
> > Unfortunately the Linux kludge won't work for Cygwin without adding new
> > stuff to Cygwin:
> >
> > - A <linux/magic.h> file, which sounds a bit weird, and
> >
> > - adding real f_type info to statfs().
> >
> > This would make less on /proc files only work starting with Cygwin 3.6,
> > but there's another, simpler solution working with all recent Cygwin
> > versions. I created a small patch to less, doing a simple path check
> > and then handling /proc files just as in the Linux-specific code:
> >
> > --- origsrc/less-643/ch.c 2023-07-21 00:43:12.000000000 +0200
> > +++ src/less-643/ch.c 2024-08-05 22:37:03.103333500 +0200
> > @@ -719,6 +719,20 @@ public void ch_flush(void)
> > }
> > }
> > }
> > +#elif defined (__CYGWIN__)
> > + if (ch_fsize == 0)
> > + {
> > + char proclink[PATH_MAX];
> > + char filename[PATH_MAX];
> > + snprintf(proclink, sizeof proclink, "/proc/%u/fd/%d",
> > + getpid(), ch_file);
> > + if (readlink(proclink, filename, sizeof filename) > 6 &&
> > + strncmp (filename, "/proc/", 6) == 0)
> > + {
> > + ch_fsize = NULL_POSITION;
> > + ch_flags &= ~CH_CANSEEK;
> > + }
> > + }
> > #endif
> > if (lseek(ch_file, (off_t)0, SEEK_SET) == BAD_LSEEK)
> >
> > Would it be ok for you to push out a new less release with this or a
> > similar patch?
>
> Current less 661 now handles that unconditionally in cl_flush() from
> ch_init():
>
> https://github.com/gwsw/less/blob/master/ch.c#L860
>
> I got rid of my ~/.lessfilter to feed 'more /proc/...' to less!
Oh, this is even better, thanks!
Corinna