Which stream does “stack smashing detected” message get printed to?

隐身守侯 提交于 2019-11-29 12:13:22

Since it's not stderr or stdout, there's only one remaining option: The controlling tty.

You can write to this with your code by opening /dev/tty.

Redirecting its output is intentionally very difficult (this is why /dev/tty is also used for password prompts). That said, if you really want to do it, expect can be used for this purpose, as can emPTY.


The easiest approach with expect is to use the included helper unbuffer, which will effectively redirect this content to stdout:

$ sh -c 'echo hello >/dev/tty' >/dev/null 2>&1
hello
$ unbuffer sh -c 'echo hello >/dev/tty' >/dev/null 2>&1
$
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!