Which Unix-like system really provides the /dev/tcp special file?
I know /dev/tcp/<host>/<port>
is a magic path handled specifically by some shells in redirections. But according to man bash
:
If the operating system on which bash is running provides these special files, bash will use them; otherwise it will emulate them internally
[...]
On the Linux box I am using right now, the /dev/tcp
special file is not present, so the Bash will emulate it. But, is there actually a Unix-like system that does provide the /dev/tcp
special file with the same semantic as the one supported by the Bash?
devices tcp character-special-files
add a comment |
I know /dev/tcp/<host>/<port>
is a magic path handled specifically by some shells in redirections. But according to man bash
:
If the operating system on which bash is running provides these special files, bash will use them; otherwise it will emulate them internally
[...]
On the Linux box I am using right now, the /dev/tcp
special file is not present, so the Bash will emulate it. But, is there actually a Unix-like system that does provide the /dev/tcp
special file with the same semantic as the one supported by the Bash?
devices tcp character-special-files
It would require an emulated directory. Making emulated directories is possible only with specific filesystems, for example procfs or sysfs can do that./dev
is a tmpfs on current linuxes, and it was on the root partition in older ones. This is why it is impossible currently. It could be made possible easily with a sysfs or procfs extension (both fs are very flexible and similar (actually probably no one knows why they aren't the same)), no one does it today, but it could be made in around 100 lines of code.
– peterh
Jan 14 at 11:58
But is there any other OS that does it already? At some point, I thought Plan 9 did it but I was wrong.
– Sylvain Leroux
Jan 14 at 12:42
1
I don't know, probably not (as far I know, it is a bash invention). I voted your question up, because the answer is interesting also to me. As far I know, no popular x86-capable unix OS can do this.
– peterh
Jan 14 at 12:44
add a comment |
I know /dev/tcp/<host>/<port>
is a magic path handled specifically by some shells in redirections. But according to man bash
:
If the operating system on which bash is running provides these special files, bash will use them; otherwise it will emulate them internally
[...]
On the Linux box I am using right now, the /dev/tcp
special file is not present, so the Bash will emulate it. But, is there actually a Unix-like system that does provide the /dev/tcp
special file with the same semantic as the one supported by the Bash?
devices tcp character-special-files
I know /dev/tcp/<host>/<port>
is a magic path handled specifically by some shells in redirections. But according to man bash
:
If the operating system on which bash is running provides these special files, bash will use them; otherwise it will emulate them internally
[...]
On the Linux box I am using right now, the /dev/tcp
special file is not present, so the Bash will emulate it. But, is there actually a Unix-like system that does provide the /dev/tcp
special file with the same semantic as the one supported by the Bash?
devices tcp character-special-files
devices tcp character-special-files
asked Jan 14 at 11:25


Sylvain LerouxSylvain Leroux
478212
478212
It would require an emulated directory. Making emulated directories is possible only with specific filesystems, for example procfs or sysfs can do that./dev
is a tmpfs on current linuxes, and it was on the root partition in older ones. This is why it is impossible currently. It could be made possible easily with a sysfs or procfs extension (both fs are very flexible and similar (actually probably no one knows why they aren't the same)), no one does it today, but it could be made in around 100 lines of code.
– peterh
Jan 14 at 11:58
But is there any other OS that does it already? At some point, I thought Plan 9 did it but I was wrong.
– Sylvain Leroux
Jan 14 at 12:42
1
I don't know, probably not (as far I know, it is a bash invention). I voted your question up, because the answer is interesting also to me. As far I know, no popular x86-capable unix OS can do this.
– peterh
Jan 14 at 12:44
add a comment |
It would require an emulated directory. Making emulated directories is possible only with specific filesystems, for example procfs or sysfs can do that./dev
is a tmpfs on current linuxes, and it was on the root partition in older ones. This is why it is impossible currently. It could be made possible easily with a sysfs or procfs extension (both fs are very flexible and similar (actually probably no one knows why they aren't the same)), no one does it today, but it could be made in around 100 lines of code.
– peterh
Jan 14 at 11:58
But is there any other OS that does it already? At some point, I thought Plan 9 did it but I was wrong.
– Sylvain Leroux
Jan 14 at 12:42
1
I don't know, probably not (as far I know, it is a bash invention). I voted your question up, because the answer is interesting also to me. As far I know, no popular x86-capable unix OS can do this.
– peterh
Jan 14 at 12:44
It would require an emulated directory. Making emulated directories is possible only with specific filesystems, for example procfs or sysfs can do that.
/dev
is a tmpfs on current linuxes, and it was on the root partition in older ones. This is why it is impossible currently. It could be made possible easily with a sysfs or procfs extension (both fs are very flexible and similar (actually probably no one knows why they aren't the same)), no one does it today, but it could be made in around 100 lines of code.– peterh
Jan 14 at 11:58
It would require an emulated directory. Making emulated directories is possible only with specific filesystems, for example procfs or sysfs can do that.
/dev
is a tmpfs on current linuxes, and it was on the root partition in older ones. This is why it is impossible currently. It could be made possible easily with a sysfs or procfs extension (both fs are very flexible and similar (actually probably no one knows why they aren't the same)), no one does it today, but it could be made in around 100 lines of code.– peterh
Jan 14 at 11:58
But is there any other OS that does it already? At some point, I thought Plan 9 did it but I was wrong.
– Sylvain Leroux
Jan 14 at 12:42
But is there any other OS that does it already? At some point, I thought Plan 9 did it but I was wrong.
– Sylvain Leroux
Jan 14 at 12:42
1
1
I don't know, probably not (as far I know, it is a bash invention). I voted your question up, because the answer is interesting also to me. As far I know, no popular x86-capable unix OS can do this.
– peterh
Jan 14 at 12:44
I don't know, probably not (as far I know, it is a bash invention). I voted your question up, because the answer is interesting also to me. As far I know, no popular x86-capable unix OS can do this.
– peterh
Jan 14 at 12:44
add a comment |
1 Answer
1
active
oldest
votes
I think the Bash documentation is somewhat misleading on this topic. Looking at the code, even going back to version 2.04 where network redirections were introduced, /dev/tcp
and /dev/udp
works as follows:
- at build time, the
configure
script checks to see whether various networking features are supported; if so, if network redirections are enabled (which is the case by default), internal networking code is built in; - at run time, if the internal networking code is built in,
/dev/tcp
and/dev/udp
(in the right format) are handled internally; otherwise, a warning is produced (“/dev/(tcp|udp)/host/port not supported without networking”) and Bash attempts to open the given path on the system; - if network redirections are configured out, nothing special is done.
What this boils down to is:
- if network redirection is enabled:
- if networking is supported on the target platform,
/dev/tcp
and/dev/udp
will always be handled internally; - otherwise, Bash will warn and try to open the file “blindly”; if the system somehow supports
/dev/(tcp|udp)/host/port
, that will be used, otherwise in all likelihood the redirection will fail;
- if networking is supported on the target platform,
- if network redirection is disabled, no special handling is performed; as above, if the system somehow supports
/dev/(tcp|udp)/host/port
, that will be used, otherwise in all likelihood the redirection will fail.
/dev/tcp
does exist on some systems, but as far as I’m aware none support the same abstraction as Bash. On Solaris, /dev/tcp
is used with the ndd
tool to query and change network configuration. In XTI (see also the Open Group if you’re a member), the t_open
function can be used with /dev/tcp
to open a TCP connection, but it doesn’t use path-based setup, there’s a separate data structure to specify the target host and port (and other parameters).
The feature itself comes from ksh93. /dev/tcp on SysV systems would be a handle on the STREAMS tcp module.
– Stéphane Chazelas
Jan 14 at 17:00
add a comment |
Your Answer
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "106"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494389%2fwhich-unix-like-system-really-provides-the-dev-tcp-special-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
I think the Bash documentation is somewhat misleading on this topic. Looking at the code, even going back to version 2.04 where network redirections were introduced, /dev/tcp
and /dev/udp
works as follows:
- at build time, the
configure
script checks to see whether various networking features are supported; if so, if network redirections are enabled (which is the case by default), internal networking code is built in; - at run time, if the internal networking code is built in,
/dev/tcp
and/dev/udp
(in the right format) are handled internally; otherwise, a warning is produced (“/dev/(tcp|udp)/host/port not supported without networking”) and Bash attempts to open the given path on the system; - if network redirections are configured out, nothing special is done.
What this boils down to is:
- if network redirection is enabled:
- if networking is supported on the target platform,
/dev/tcp
and/dev/udp
will always be handled internally; - otherwise, Bash will warn and try to open the file “blindly”; if the system somehow supports
/dev/(tcp|udp)/host/port
, that will be used, otherwise in all likelihood the redirection will fail;
- if networking is supported on the target platform,
- if network redirection is disabled, no special handling is performed; as above, if the system somehow supports
/dev/(tcp|udp)/host/port
, that will be used, otherwise in all likelihood the redirection will fail.
/dev/tcp
does exist on some systems, but as far as I’m aware none support the same abstraction as Bash. On Solaris, /dev/tcp
is used with the ndd
tool to query and change network configuration. In XTI (see also the Open Group if you’re a member), the t_open
function can be used with /dev/tcp
to open a TCP connection, but it doesn’t use path-based setup, there’s a separate data structure to specify the target host and port (and other parameters).
The feature itself comes from ksh93. /dev/tcp on SysV systems would be a handle on the STREAMS tcp module.
– Stéphane Chazelas
Jan 14 at 17:00
add a comment |
I think the Bash documentation is somewhat misleading on this topic. Looking at the code, even going back to version 2.04 where network redirections were introduced, /dev/tcp
and /dev/udp
works as follows:
- at build time, the
configure
script checks to see whether various networking features are supported; if so, if network redirections are enabled (which is the case by default), internal networking code is built in; - at run time, if the internal networking code is built in,
/dev/tcp
and/dev/udp
(in the right format) are handled internally; otherwise, a warning is produced (“/dev/(tcp|udp)/host/port not supported without networking”) and Bash attempts to open the given path on the system; - if network redirections are configured out, nothing special is done.
What this boils down to is:
- if network redirection is enabled:
- if networking is supported on the target platform,
/dev/tcp
and/dev/udp
will always be handled internally; - otherwise, Bash will warn and try to open the file “blindly”; if the system somehow supports
/dev/(tcp|udp)/host/port
, that will be used, otherwise in all likelihood the redirection will fail;
- if networking is supported on the target platform,
- if network redirection is disabled, no special handling is performed; as above, if the system somehow supports
/dev/(tcp|udp)/host/port
, that will be used, otherwise in all likelihood the redirection will fail.
/dev/tcp
does exist on some systems, but as far as I’m aware none support the same abstraction as Bash. On Solaris, /dev/tcp
is used with the ndd
tool to query and change network configuration. In XTI (see also the Open Group if you’re a member), the t_open
function can be used with /dev/tcp
to open a TCP connection, but it doesn’t use path-based setup, there’s a separate data structure to specify the target host and port (and other parameters).
The feature itself comes from ksh93. /dev/tcp on SysV systems would be a handle on the STREAMS tcp module.
– Stéphane Chazelas
Jan 14 at 17:00
add a comment |
I think the Bash documentation is somewhat misleading on this topic. Looking at the code, even going back to version 2.04 where network redirections were introduced, /dev/tcp
and /dev/udp
works as follows:
- at build time, the
configure
script checks to see whether various networking features are supported; if so, if network redirections are enabled (which is the case by default), internal networking code is built in; - at run time, if the internal networking code is built in,
/dev/tcp
and/dev/udp
(in the right format) are handled internally; otherwise, a warning is produced (“/dev/(tcp|udp)/host/port not supported without networking”) and Bash attempts to open the given path on the system; - if network redirections are configured out, nothing special is done.
What this boils down to is:
- if network redirection is enabled:
- if networking is supported on the target platform,
/dev/tcp
and/dev/udp
will always be handled internally; - otherwise, Bash will warn and try to open the file “blindly”; if the system somehow supports
/dev/(tcp|udp)/host/port
, that will be used, otherwise in all likelihood the redirection will fail;
- if networking is supported on the target platform,
- if network redirection is disabled, no special handling is performed; as above, if the system somehow supports
/dev/(tcp|udp)/host/port
, that will be used, otherwise in all likelihood the redirection will fail.
/dev/tcp
does exist on some systems, but as far as I’m aware none support the same abstraction as Bash. On Solaris, /dev/tcp
is used with the ndd
tool to query and change network configuration. In XTI (see also the Open Group if you’re a member), the t_open
function can be used with /dev/tcp
to open a TCP connection, but it doesn’t use path-based setup, there’s a separate data structure to specify the target host and port (and other parameters).
I think the Bash documentation is somewhat misleading on this topic. Looking at the code, even going back to version 2.04 where network redirections were introduced, /dev/tcp
and /dev/udp
works as follows:
- at build time, the
configure
script checks to see whether various networking features are supported; if so, if network redirections are enabled (which is the case by default), internal networking code is built in; - at run time, if the internal networking code is built in,
/dev/tcp
and/dev/udp
(in the right format) are handled internally; otherwise, a warning is produced (“/dev/(tcp|udp)/host/port not supported without networking”) and Bash attempts to open the given path on the system; - if network redirections are configured out, nothing special is done.
What this boils down to is:
- if network redirection is enabled:
- if networking is supported on the target platform,
/dev/tcp
and/dev/udp
will always be handled internally; - otherwise, Bash will warn and try to open the file “blindly”; if the system somehow supports
/dev/(tcp|udp)/host/port
, that will be used, otherwise in all likelihood the redirection will fail;
- if networking is supported on the target platform,
- if network redirection is disabled, no special handling is performed; as above, if the system somehow supports
/dev/(tcp|udp)/host/port
, that will be used, otherwise in all likelihood the redirection will fail.
/dev/tcp
does exist on some systems, but as far as I’m aware none support the same abstraction as Bash. On Solaris, /dev/tcp
is used with the ndd
tool to query and change network configuration. In XTI (see also the Open Group if you’re a member), the t_open
function can be used with /dev/tcp
to open a TCP connection, but it doesn’t use path-based setup, there’s a separate data structure to specify the target host and port (and other parameters).
answered Jan 14 at 13:27
Stephen KittStephen Kitt
172k24386464
172k24386464
The feature itself comes from ksh93. /dev/tcp on SysV systems would be a handle on the STREAMS tcp module.
– Stéphane Chazelas
Jan 14 at 17:00
add a comment |
The feature itself comes from ksh93. /dev/tcp on SysV systems would be a handle on the STREAMS tcp module.
– Stéphane Chazelas
Jan 14 at 17:00
The feature itself comes from ksh93. /dev/tcp on SysV systems would be a handle on the STREAMS tcp module.
– Stéphane Chazelas
Jan 14 at 17:00
The feature itself comes from ksh93. /dev/tcp on SysV systems would be a handle on the STREAMS tcp module.
– Stéphane Chazelas
Jan 14 at 17:00
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f494389%2fwhich-unix-like-system-really-provides-the-dev-tcp-special-file%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
It would require an emulated directory. Making emulated directories is possible only with specific filesystems, for example procfs or sysfs can do that.
/dev
is a tmpfs on current linuxes, and it was on the root partition in older ones. This is why it is impossible currently. It could be made possible easily with a sysfs or procfs extension (both fs are very flexible and similar (actually probably no one knows why they aren't the same)), no one does it today, but it could be made in around 100 lines of code.– peterh
Jan 14 at 11:58
But is there any other OS that does it already? At some point, I thought Plan 9 did it but I was wrong.
– Sylvain Leroux
Jan 14 at 12:42
1
I don't know, probably not (as far I know, it is a bash invention). I voted your question up, because the answer is interesting also to me. As far I know, no popular x86-capable unix OS can do this.
– peterh
Jan 14 at 12:44