0

When I run:

$ cat /dev/random

on OS X 10.9, after a short period of time, a print dialog pops up asking me if I want to print gibberish (iTerm2).

Using the native terminal application, it just crashes.

I understand that /dev/random produces noise but why does this print dialog randomly show up and why does the native terminal application crash?

bneely
  • 9,083
  • 4
  • 38
  • 46
  • 1
    I think there's a terminal control sequence that makes the printer print things, but it seems unlikely that it would be produced every time you cat /dev/random and always after a "short period of time." – jwodder Dec 10 '13 at 23:46
  • Indeed. I tried `cat /dev/random` and after about 10 seconds of gibberish, Terminal.app died and I had to relaunch it. – rob mayoff Dec 10 '13 at 23:47
  • Interesting that the control sequence would be interpreted rather than just displayed. I supposed this is for other things such as alerts though you would imagine it checking what it is and printing it to the terminal if it is not a control signal. Therefore, this means that you can make the OS print via a terminal application? Pretty cool. – user1371383 Dec 11 '13 at 00:18
  • @user1371383: control sequences such as cursor positioning work exactly that way which how programs that draw on the screen like editors work. You can find more on the topic here: http://en.wikipedia.org/wiki/Terminal_capabilities – Perry Dec 12 '13 at 01:31

1 Answers1

2

You've inadvertently tripped over the concept of Fuzz Testing (http://en.wikipedia.org/wiki/Fuzz_testing) in which software is tested using random inputs in an effort to make it crash or act unexpectedly.

The mechanism at play is that a terminal application interprets every character it's sent to see if it should perform some special function such as bolding text, ringing the "bell" or even printing the screen.

Report any bugs you find to the software makers (though a common response to bugs discovered through fuzz testing is "well don't do that").

Perry
  • 1,152
  • 10
  • 14
  • 1
    But if there *is* a control sequence for printing the screen, then iTerm2 is behaving as it should. The only bug is in the program that crashes, and that's made by Apple. – jwodder Dec 11 '13 at 00:15