[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: No such device or address when opening /dev/fd/<x> on opened /dev/tc
From: |
Chet Ramey |
Subject: |
Re: No such device or address when opening /dev/fd/<x> on opened /dev/tcp socket |
Date: |
Mon, 5 Apr 2021 14:46:26 -0400 |
User-agent: |
Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:78.0) Gecko/20100101 Thunderbird/78.9.0 |
On 4/5/21 1:31 PM, konsolebox wrote:
Not sure if this is a bug or a limitation but this works:
# echo a | ( exec {fd}>/path/to/regular/file; tee /dev/fd/"$fd" )
While this produces a "No such device or address" error:
# echo a | ( exec {fd}>/dev/tcp/host/port; tee /dev/fd/"$fd" )
There's no guarantee that file descriptors opened with socket(2) show up in
/dev/fd. Bash doesn't emulate /dev/fd if the system provides it, so it's up
to the OS on those systems whether they do or not.
It doesn't generate that error on macOS, for instance, which has /dev/fd.
--
``The lyf so short, the craft so long to lerne.'' - Chaucer
``Ars longa, vita brevis'' - Hippocrates
Chet Ramey, UTech, CWRU chet@case.edu http://tiswww.cwru.edu/~chet/
Re: No such device or address when opening /dev/fd/<x> on opened /dev/tcp socket, konsolebox, 2021/04/05