''gpg: failed to translate osfhandle 0x00000003' known|expected? -fd 4-7 doesn't.

Werner Koch wk at gnupg.org
Mon Mar 25 17:20:28 CET 2024

On Mon, 25 Mar 2024 08:33, Bee said:

> C:\Program Files (x86)\GnuPG\bin>type HelloWorld.txt | .\gpg.exe --passphrase-fd 3 -c  3< HelloWorld.txt
>> gpg: failed to translate osfhandle 0x00000003

gpg takes system handles and not libc file descriptors.  File
descriptors 0, 1, and 2 are handled by Windows in a different.  All
other depend on which ABI you work.  cmd.exe seems to expect file
descriptors which is good for scripting but gpg is rarely used in such a
scripting environment but usuallay directly executed by CreateProcess
and thus expects HANDLE values and not file descriptors.

See gnupg/common/sysutils.c:translate_sys2libc_fd

Actually it would be possible to provide an option to disable this
translation and instead use libc file descriptors (with all the fun if
different runtimes are used) but in more than 20 years we have not seen
such a demand.



The pioneers of a warless world are the youth that
refuse military service.             - A. Einstein
-------------- next part --------------
A non-text attachment was scrubbed...
Name: openpgp-digital-signature.asc
Type: application/pgp-signature
Size: 247 bytes
Desc: not available
URL: <https://lists.gnupg.org/pipermail/gnupg-users/attachments/20240325/88f5f83b/attachment.sig>

More information about the Gnupg-users mailing list