Unix Man ( )


LOCKING(3) - 2


locking ocae aao opyeoo yaca o eye o aa. Ta oceoaeoc oepaopo, opya peye yaco ae, oe ceye:

fd=open("datafile",O_RDWR); lseek(fd,200L,0); locking(fd,LK_LOCK,200L);

opoa paopoa eoo aa yo ycao yaae o a aao aa ae cea o locking c size, pa 0.

size aae co oceoaex ao (y yaca), oope opyc paopyc. aco, oop oe opoa, aaec o eye o ae. Ec size pao 0, opyec paopyec ec a (acao o 2 30 cee ao). size oe aaa pay pay a oo aa; o cyae oo poecc, opoa o yaco, oe oya ocy aa yp oo yaca.

Boooc ao opo (ya) oae oa, oa poecc, e opoa yaco, pocaaaec p oe opoa yaco, opoa ye py poecco. ooy y , read(3) write(3) poep oooc ya pee, e epeec poecc oae. Ec oapyea oooc ya, cpyec oa [EDEADLK] ( [EDEADLOCK]) ece e oec.

opye yaco (ec eo ac) oe coepac paee opoao yace. B o cyae, a ae ec yac cee, yac oec o yaco p yco coacoa peo opo. Ec pe epeceaxc yaco pa, oeee ooo p yoeope oceeo yaaoo pea. Ta opao, ec yaco, opye o ac, coaae ec ac yaca, opoaoo paee e e poecco o e ac, o yaco ye opoa oo o e, a ocaac ac peeo yaca, ec oa ec, ye pooa opoao o e ac. Ha co opyex ae yaco opae e, o ec opaee a oee co opoax yaco ccee. XENIX o opaee pao 200.

apoc a paopoae oe paopoa ooc aco ecoo yaco, opoax a poecco. Ec yac paopyc e ooc, ocaec yac ocac opoa e e poecco. Paopoae cepe yaca po oe yx opoax yaco, .e. oae ooo eea ae opoax yaco. Ec aa ye oa, cpyec oa ece e oec. Paopoa yaco oe oo o poecc, oop eo opoa. Paopoae yaca, oop e opoa, ye paopoa, e eae eo. p aepe poecca ce opoae yac paopyc.

Ec poecc op a oee ooo paa, ce ceae poecco o ae opo yoac p epo ap aa.

peee opo ceaoy ay popaoy aay e opaae o, o p oepax e/ac c ao opoa oppyec. He pe opoy aaoy.

.


creat(3), open(3), read(3), write(3), dup(3), close(3), lseek(3)


B cyae o locking opaae (int)-1. Ec p opoe c peo LK_LOCK LK_RLCK yaco oaaec ye opoa, XENIX System V aoc errno EAGAIN. XENIX 3.0 o cyae aoc errno EACCES. Ec opoa peec aaoy, errno aocc EACCES. Ec ooe y, errno aocc EDEADLK ( EDEADLOCK). Tao e o o aocc p epeoe cceo a opoax yaco.