Created attachment 470608 [details, diff] STDIO workaround patch This is a known bug: https://github.com/crystal-lang/crystal/issues/2065 The problem is the following: $ su - password: # logout $ crystal Usage: crystal [command] [switches] [program file] [--] [arguments] Command: init generate a new project build build an executable deps install project dependencies docs generate documentation env print Crystal environment information eval eval code from args or standard input play starts crystal playground server run (default) build and run program spec build and run specs (in spec directory) tool run a tool help, --help, -h show this help version, --version, -v show version $ su - Authentication token manipulation error I've, successfully, patched the compiler with a suggestion from RX14 @ freenode#crystal-lang. I will attach the patch that enables a workaround I've tested it and it works.
Thanks for the patch! AFAIU your change switches stdio descriptors to blocking at program startup time (not shutdown time). I have no idea how crystal-lang's runtime works but I would imagine the fix to cause occasional locks and pauses of runtime. Typical example would be something like the following: - two threads both block on read() from stdin at the same time - libevent queues read calls into epoll() - user inputs data - both threads are unpaused by libevent and rescheduled for execution - one of threads does read() syscall and reads out whole user output - another thread calls read() syscall on empty STDIN and blocks the runtime Maybe it's not too bad as it's a special corner case. I'll apply your workaround tomorrow if there will be no change in original bug.
Pushed your patch as: https://gitweb.gentoo.org/repo/gentoo.git/commit/?id=3cf9beab238c015964bb1c8193d9a4394fce3a21 Please note it's not enabled by default and needs USE=blocking-stdio-hack: """ dev-lang/crystal: Workaround tty corruption in crystal, bug #616256 Patch restores blocking mode of file desriptors in exchange of potential runtime deadlocks when dealing with stdio. As it's a potentially invasive patch it's not enabled by default and is available only under USE=blocking-stdio-hack """ Thank you!
Cool, man. Thanks a lot.