Re: FVWM: Make fvwm-root read from stdin?

From: Dan Espen <dane_at_mk.telcordia.com>
Date: Fri, 03 Jun 2005 10:58:47 -0400

"Mark A. Nicolosi" <m.a.nicolosi_at_att.net> writes:
> Hi,
>
> I'm trying to get fvwm-root to use an image piped to it. I thought if I
> used /dev/stdin as the filename it would work. It doesn't. I'm using
> this command:
>
> $ convert file.jpg png:/dev/stdout | fvwm-root -r /dev/stdin
>
> This is what I get:
> [fvwm-root] failed to load image file '/proc/self/fd/0'
>
> /dev/stdin being a symlink isn't the problem. I checked to see if
> fvwm-root decides if the file is a png or xpm by extension or content.
> It decides by content (ie I copied file.png to file and tried it).
>
> Is this a bug? Is there a way around it? I guess I could use temporary
> files, but that ugly...

I don't think it's a bug.

If you use strace to follow what goes on, Fvwm first checks
to see if the file is an XPM file. It does that by reading
the first 4K of the file:

open("/dev/stdin", O_RDONLY) = 4
read(4, "\211PNG\r\n\32\n\0\0\0\rIHDR\0\0\1_at_\0\0\0\360\10\2\0\0"..., 4096) = 4096
close(4) = 0

Since the file is PNG, that fails and it then tries XPM:

open("/dev/stdin", O_RDONLY) = 4
read(4, "\350\362\201\217\24W\2425_\7 \365T\316rV\267\331\f\30\274"..., 4096) = 4096
close(4) = 0

That fails too, since the first 4K of stdin has already been read.
Notice how the input data is different.

The problem is that /dev/stdin is a FIFO, once you read it, you can't
close it and expect to read the same thing again.

If you use convert to change the file to an XPM, fvwm-root HAPPENS to
work, but that's just because right now it tries XPM first.


-- 
Dan Espen                           E-mail: dane_at_mk.telcordia.com
--
Visit the official FVWM web page at <URL: http://www.fvwm.org/>.
To unsubscribe from the list, send "unsubscribe fvwm" in the body of a
message to majordomo_at_fvwm.org.
To report problems, send mail to fvwm-owner_at_fvwm.org.
Received on Fri Jun 03 2005 - 09:59:41 BST

This archive was generated by hypermail 2.3.0 : Mon Aug 29 2016 - 19:37:57 BST