Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

showkey couldn't get a file descriptor referring to the console #1806

Open
artemsnisarenko opened this issue Mar 23, 2017 · 6 comments
Open
Labels

Comments

@artemsnisarenko
Copy link

showkey doesn't work with --scancodes or --keycodes (default) options. Saying that it

Couldn't get a file descriptor referring to the console

Windows build 14393.953

$ strace showkey
execve("/usr/bin/showkey", ["showkey"], [/* 15 vars */]) = 0
brk(0) = 0x15f4000
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1f36840000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=20672, ...}) = 0
mmap(NULL, 20672, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1f3684a000
close(3) = 0
access("/etc/ld.so.nohwcap", F_OK) = -1 ENOENT (No such file or directory)
open("/lib/x86_64-linux-gnu/libc.so.6", O_RDONLY|O_CLOEXEC) = 3
read(3, "\177ELF\2\1\1\0\0\0\0\0\0\0\0\0\3\0>\0\1\0\0\0\320\37\2\0\0\0\0\0"..., 832) = 832
fstat(3, {st_mode=S_IFREG|0755, st_size=1840928, ...}) = 0
mmap(NULL, 3949248, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 3, 0) = 0x7f1f36230000
mprotect(0x7f1f363eb000, 2093056, PROT_NONE) = 0
mmap(0x7f1f365ea000, 24576, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_DENYWRITE, 3, 0x1ba000) = 0x7f1f365ea000
mmap(0x7f1f365f0000, 17088, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|MAP_ANONYMOUS, -1, 0) = 0x7f1f365f0000
close(3) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1f36830000
mmap(NULL, 8192, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1f36820000
arch_prctl(ARCH_SET_FS, 0x7f1f36820740) = 0
mprotect(0x7f1f365ea000, 16384, PROT_READ) = 0
mprotect(0x602000, 4096, PROT_READ) = 0
mprotect(0x7f1f36822000, 4096, PROT_READ) = 0
munmap(0x7f1f3684a000, 20672) = 0
brk(0) = 0x15f4000
brk(0x1615000) = 0x1615000
open("/usr/lib/locale/locale-archive", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2919792, ...}) = 0
mmap(NULL, 2919792, PROT_READ, MAP_PRIVATE, 3, 0) = 0x7f1f35f67000
close(3) = 0
open("/proc/self/fd/0", O_RDWR) = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(3, KDGKBTYPE, 0x7fffe9233c4f) = -1 ENOTTY (Inappropriate ioctl for device)
close(3) = 0
open("/dev/tty", O_RDWR) = 3
ioctl(3, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(3, KDGKBTYPE, 0x7fffe9233c4f) = -1 ENOTTY (Inappropriate ioctl for device)
close(3) = 0
open("/dev/tty0", O_RDWR) = -1 EIO (Input/output error)
open("/dev/tty0", O_WRONLY) = -1 EIO (Input/output error)
open("/dev/tty0", O_RDONLY) = -1 EIO (Input/output error)
open("/dev/vc/0", O_RDWR) = -1 ENOENT (No such file or directory)
open("/dev/vc/0", O_WRONLY) = -1 ENOENT (No such file or directory)
open("/dev/vc/0", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/dev/systty", O_RDWR) = -1 ENOENT (No such file or directory)
open("/dev/systty", O_WRONLY) = -1 ENOENT (No such file or directory)
open("/dev/systty", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/dev/console", O_RDWR) = -1 ENOENT (No such file or directory)
open("/dev/console", O_WRONLY) = -1 ENOENT (No such file or directory)
open("/dev/console", O_RDONLY) = -1 ENOENT (No such file or directory)
ioctl(0, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(0, KDGKBTYPE, 0x7fffe9233c4f) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(1, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(1, KDGKBTYPE, 0x7fffe9233c4f) = -1 ENOTTY (Inappropriate ioctl for device)
ioctl(2, SNDCTL_TMR_TIMEBASE or SNDRV_TIMER_IOCTL_NEXT_DEVICE or TCGETS, {B38400 opost isig icanon echo ...}) = 0
ioctl(2, KDGKBTYPE, 0x7fffe9233c4f) = -1 ENOTTY (Inappropriate ioctl for device)
open("/usr/share/locale/locale.alias", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=2570, ...}) = 0
mmap(NULL, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0) = 0x7f1f36810000
read(3, "# Locale name alias data base.\n#"..., 512) = 512
read(3, "PURPOSE. See the\n# GNU General "..., 512) = 512
read(3, " entries are case independent.\n\n"..., 512) = 512
read(3, "859-1\nfinnish fi_FI.ISO-"..., 512) = 512
read(3, "R\nko_KR\t\tko_KR.eucKR\nlithuanian "..., 512) = 512
read(3, "SO-8859-9\n", 512) = 10
read(3, "", 512) = 0
close(3) = 0
munmap(0x7f1f36810000, 4096) = 0
open("/usr/share/locale/en_US.UTF-8/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US.utf8/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en_US/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.UTF-8/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en.utf8/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale/en/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.UTF-8/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US.utf8/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en_US/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.UTF-8/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en.utf8/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
open("/usr/share/locale-langpack/en/LC_MESSAGES/kbd.mo", O_RDONLY) = -1 ENOENT (No such file or directory)
write(2, "Couldn't get a file descriptor r"..., 56Couldn't get a file descriptor referring to the console
) = 56
exit_group(1) = ?
+++ exited with 1 +++

@stehufntdev
Copy link
Collaborator

Thanks for reporting the issue. Based on the strace above, this is due to WSL not supporting the virtual console device (i.e. /dev/tty0). This is an interesting device for WSL since there isn't a direct mapping of virtual console, though one idea would be to use the top most bash console window. Please help us prioritize this scenario by giving feedback on user voice - https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/.

@mxdog
Copy link

mxdog commented Mar 30, 2018

stdbuf -oL showkey -s | while read line
do
if [[ "$line" =~ '^0x' ]]
then
for code in ${(z)line}
do
printf "0%o " $code
done
echo
else
echo $line
fi
done

I was trying to work some key-press issues in some scripts and ran into this also.

@vbrozik
Copy link

vbrozik commented Sep 27, 2021

Please help us prioritize this scenario by giving feedback on user voice - https://wpdev.uservoice.com/forums/266908-command-prompt-console-bash-on-ubuntu-on-windo/.

This UserVoice instance is no longer available.

Is there any voting replacement instead of the discontinued UserVoice instance?

@KattKriger
Copy link

Same as @vbrozik
I cannot use the command in Xubuntu20

@max-len
Copy link

max-len commented Jul 21, 2022

Works with sudo showkey on my machine.

Windows Terminal
Version: 1.13.11431.0
5.10.102.1-microsoft-standard-WSL2
Ubuntu 22.04 LTS

@gamepad-coder
Copy link

showkey does not work for me.
showkey -a does work for me.

image

Sudo not required on my machine for showkey -a.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

8 participants