On +2022-06-25 19:40:48 +0200, Maxime Devos wrote: > Chris Marusich schreef op za 25-06-2022 om 09:52 [-0700]: > > Yes, I agree those are good reasons to avoid a temporary file if we > > can. > > To that end, do you know if we can somehow force Guile to use a > > specific > > file descriptor for the pipe?  In the patch I wrote earlier, which > > uses > > redirection, the problem was that I could not control Guile's choice > > of > > file descriptors.  Guile chose file descriptor 19 for one end of the > > pipe, and I don't know how to make it use anything else.  If we can > > arrange for Guile to consistently use file descriptor 7, for example, > > then probably it would work in all the shell I've tested. > > > > I wonder if maybe I can just duplicate the file descriptor?  I don't > > know; if for example Guile reserves all the file descriptors below 10 > > for other uses, it might be hard. > > > > Have a look at ‘(guile)Ports and File Descriptors’. It has lots of > procedures for duplicating and renumbering. That's fragile though, you > might accidentally overwrite an fd that's being used for something > else. > > (Normally move->fdes would prevent overwriting things by moving pre- > existing fds out of the way, adjusting ports automatically, but move- > >fdes doesn't know (yet) about the pipe that Guile uses for > finalisation, see maybe: > ) > > I think it would be best to patch the dash appropriately (though fixing > move->fdes would be nice too). > > Greetings, > Maximee. Could this help?: (from man 2 openat (scroll down a fair bit): -8<---------------cut here---------------start------------->8--- There are two main use cases for O_TMPFILE: * Improved tmpfile(3) functionality: race-free creation of temporary files that (1) are automatically deleted when closed; (2) can never be reached via any pathname; (3) are not subject to symlink at‐ tacks; and (4) do not require the caller to devise unique names. * Creating a file that is initially invisible, which is then populated with data and adjusted to have appropriate filesystem attributes (fchown(2), fchmod(2), fsetxattr(2), etc.) before being atomi‐ cally linked into the filesystem in a fully formed state (using linkat(2) as described above). O_TMPFILE requires support by the underlying filesystem; only a subset of Linux filesystems provide that support. In the initial implementation, support was provided in the ext2, ext3, ext4, UDF, Minix, and shmem filesystems. Support for other filesystems has subsequently been added as follows: XFS (Linux 3.15); Btrfs (Linux 3.16); F2FS (Linux 3.16); and ubifs (Linux 4.9) --8<---------------cut here---------------end--------------->8--- BTW, IIRC, this can be used to create an invisible file that can be mmap-ed, and the mmap will persist when you delete the file. Which then can be used as an anonymous buffer passed to wayland, along with metadate saying what the buffer contains, e.g. different kinds of rgb or rgba permutations and encodings, (or anything, which you can tell wayland just to keep track of for you. You need a directory for openat, so probably XDG_RUNTIME_DIR=/run/user/1000 is suitable if it exists. Worked in my case. HTH -- Regards, Bengt Richter