我在Ubuntu 10.04 LTS下編譯了以下代碼和gcc版本4.4.3(Ubuntu 4.4.3-4ubuntu5)。Linux - 爲什麼錯誤消息在調用寫入後不顯示(2,「...」)?
[email protected]:~/doc$ cat simple_write.c
#include <unistd.h>
#include <stdlib.h>
int main()
{
if ((write(1, "Here is some data\n", 18)) != 18)
write(2, "A write error has occurred on file descriptor 1\n",46);
exit(0);
}
[email protected]:~/doc$ ./simple_write
Here is some data
有人可以向我解釋爲什麼第二個錯誤消息不打印? 它被重定向到其他地方嗎?那麼,如何讓它顯示出來?
謝謝
......真的嗎? – 2011-04-27 03:28:42