4 ms·
The implementation in musl libc is a simple ioctl call[0], so really it should be available in all languages without need for a C FFI. I always find this kind o
by fao_ 7y ago
The implementation in musl libc is a simple ioctl call[0], so really it should be available in all languages without need for a C FFI. I always find this kind of thing interesting.
[0]: https://git.musl-libc.org/cgit/musl/tree/src/unistd/isatty.c https://git.musl-libc.org/cgit/musl/tree/src/unistd/isatty.c
- skissane 7y agoioctl is inherently non-portable. Even though most Unix-like OS implement it, it is not part of the POSIX / SUS standard and so code which relies on it is a portability problem. The problem is the ioctl command codes and their parameters are not standardised and vary from OS to OS. (The POSIX standard does standardise ioctl, but only for use with STREAMS, which is an optional feature which more often than not isn't implemented.)
- cperciva 7y agoJust to be clear, while ioctl has issues, isatty is part of the POSIX standard: https://pubs.opengroup.org/onlinepubs/9699919799/functions/isatty.html https://pubs.opengroup.org/onlinepubs/9699919799/functions/i...
- chrisseaton 7y agoHow would you do an ioctl from Java without an FFI?
- matheusmoreira 7y agoThe JIT compiler could have support for emitting system calls.
- chrisseaton 7y agoThat's not what I meant. I meant there is no ioctl method in the Java standard library. So how do you call it without using some FFI to import the method? You cannot.