GNOME Bugzilla – Bug 797344
gst-inspect: Pipe stdout to less if not piped already
Last modified: 2018-10-28 13:20:40 UTC
Just like all git commands do. Everyone I talked to at the GStreamer conference 2018, either liked or loved this idea so let's do it. :)
Created attachment 374067 [details] [review] gst-inspect: Pipe stdout to less if not piped already
I thought there's GLib API for doing this process stuff :)
(In reply to Sebastian Dröge (slomo) from comment #2) > I thought there's GLib API for doing this process stuff :) I didn't find a glib API for isatty() at least.
No, but for spawning processes and redirecting stdout/etc
(In reply to Sebastian Dröge (slomo) from comment #4) > No, but for spawning processes and redirecting stdout/etc I tried it but didn't manage to make it work. If this is going to be unix-specific anyway, i didn't see the point of spending time on making that work.
Review of attachment 374067 [details] [review]: Generally looks good ::: tools/gst-inspect.c @@ +1716,3 @@ + + while ((count = read (STDIN_FILENO, buffer, sizeof (buffer) - 1)) > 0) + write (STDOUT_FILENO, buffer, count); Need to handle EAGAIN/EINTR here at least
As an enhancement, I'd suggest to take a look at the PAGER env variable, which is generally used to set a viewer for things like man, for instance. git also respects it, try 'PAGER=more git log'
(In reply to Zeeshan Ali from comment #5) > (In reply to Sebastian Dröge (slomo) from comment #4) > > No, but for spawning processes and redirecting stdout/etc > > I tried it but didn't manage to make it work. If this is going to be > unix-specific anyway, i didn't see the point of spending time on making that > work. It *can* work on non-unix too. Windows cmd always had partial tty support and nowdays (latest windows 10 builds) they have implemented full support even, so it can be made to work, but I think unix-only is a good start.
Created attachment 374076 [details] [review] DOESNT WORK: gst-inspect: Pipe stdout to less if not piped already That's my attempt of using g_spawn_async_with_pipes instead. I also tried treating the returned child_stdin as the pipe itself and dup'ing the STDOUT fd over it (if that makes any sense) but that didn't work either. I think I'll have to manually create channels for both stdout and child_stdin and feed the data from former to the lattter.
(In reply to Zeeshan Ali from comment #9) > Created attachment 374076 [details] [review] [review] > DOESNT WORK: gst-inspect: Pipe stdout to less if not piped already Doesn't work == `less` never gets any data.
Review of attachment 374067 [details] [review]: ::: tools/gst-inspect.c @@ +1716,3 @@ + + while ((count = read (STDIN_FILENO, buffer, sizeof (buffer) - 1)) > 0) + write (STDOUT_FILENO, buffer, count); for the write or read or both?
Comment on attachment 374076 [details] [review] DOESNT WORK: gst-inspect: Pipe stdout to less if not piped already Good with the other API, it's simple enough
Created attachment 374078 [details] [review] gst-inspect: Pipe stdout to less if not piped already v2: * Allow setting a custom pager with PAGER env. * Handle EINTR and EAGAIN on read and write calls.
Review of attachment 374078 [details] [review]: Go for it
Attachment 374078 [details] pushed as 5d115a5 - gst-inspect: Pipe stdout to less if not piped already