我写了一个test.c:
#include <unistd.h>
#include <stdio.h>
int main()
{
while(1)
{
sleep(1);
printf("====test====\r\n");
}
return 0;
}
然后我编译它: gcc ./test.c -o ./test 我写了一个shell脚本:
#!/bin/sh
./test &
然后我让这个脚本在系统启动时自动执行。然后我使用 SSH 协议中的 secureCRT 登录 Linux 系统。使用“ps aux | grep test”我可以看到测试过程正在运行,但我只是看不到测试的输出,有人告诉我因为测试输出到 tty,而我正在使用 pts。谁能告诉我具体原因以及如何获得输出?提前致谢!