During process running , I use vim aa.txt and exec :wq ,then this process can't print any longer. Why ?
When I check process status by lsof -p pid,It show /home/ben/bypy/sederror/aa.txt~ (deleted) . By the way , testing in centos.
//test.cc
#include <iostream>
#include <fstream>
#include <unistd.h>
using namespace std;
int main()
{
ofstream file("./aa.txt");
if(!file.is_open())
{
return -1;
}
int iNum = 1;
while(1)
{
file << iNum <<endl;
iNum++;
sleep(5);
}
return 0;
}