dai un'occhiata a questa funzione nella doc PHP:

bool flock ( resource handle, int operation [, int &wouldblock] )