Bug#925116: posh: use memfd_create(2) for heredocs when available

2025-12-04 Thread Clint Adams

On Tue, Mar 19, 2019 at 05:52:05PM -0400, Daniel Kahn Gillmor wrote:

this appears to be done in the herein() function in exec.c.


Probably that should happen in io.c:maketemp() if TT_HEREDOC_EXP
is passed as the type.



Bug#925116: posh: use memfd_create(2) for heredocs when available

2019-03-19 Thread Daniel Kahn Gillmor
Package: posh
Severity: wishlist

Currently posh creates heredocs in the filesystem.  This means that
heredoc contents will unnecessarily touch the disks, and it also means
dealing with risky juggling of tempfile names.

It would be nicer, on platforms that support it, if posh could use
memfd_create(2) for its heredocs.

this appears to be done in the herein() function in exec.c.

that code currently opens the same filename twice, once read-only, and
then closes the read/write file descriptor.

if posh uses memfd_create, it will get the file descriptor in read-write
mode.  once done writing, it should probably seek() back to offset 0,
and somehow convert it to read-only (i don't know how to do that) before
returning the file descriptor directly.

  --dkg