I wrote code :
======================================
int main() {
Stdio.File f=Stdio.File("lockfile","cr");
object l=f->lock();
write("I lock the file");
sleep(8);
return -1;
}
=======================================
I run this program in two processes,one after anthoer, the second process would write "I lock the file" after 8 secconds the first process start to run.
But if i wrote
=======================================
int main() {
Stdio.File f=Stdio.File("lockfile","cr");
object l=f->lock();
write("I lock the file");

return -1;
}
=======================================
and run in two processes, one after anthoer, the second process would write "I lock the file" immediately after it started.

I want to know why this happens, and why "return -1" is not work in this situation.
I always think if I write "return -1" in the main(), the process will not quit and the file lock in the process will not destroy






  网易188财富邮--财富的象征;全新开放, 丰富用户名等您注册
  最大
5G空间,附件40兆收发;免费注册体验 http://www.188.com/