The link("old","new") will fail if "new" exists and will succeed if it can create "new". Therefore, if several processes try to create a link called "new" at once, if one succeeds, the other ones will fail. In that manner, the link system can be used to pick one process out of many. The existence of that link can be used as lock.
把link当作lock的一个小例子
main()
{
char * src ="1.txt";
char * lockname ="1.txt.lck";
lockfile(src, lockname);
fp = fopen(src,"a");
sleep(10); //at this point, it can run another instance, another instance will be pending on the "lockfile" function above.