fork()ing problem
Christos Ricudis
ricudis at paiko.gr
Sat Dec 8 11:26:02 EET 2001
Hello Andreou!
On 08 Dec 01, Andreou Al. wrote to All with subject "fork()ing problem":
AA> to opoio to egrapsa gia na dw ti ginetai otan yparxei ta pids
AA> ftasoun sto 65535, kai gia na dw ligo tis fork(), getpid(), getppid().
Nomizw einai implementation-dependent. Sto Linux, otan ftasoun sto 65535,
kanoun wrap around sto 0 kai xrhsimopoioyn apo kei opoio PID broun eley8ero.
Alla leitourgika pairnoun ena semi-random PID san to next available PID , wste
na apo8arrynoyn diafora exploits apo to na 'manteyoyn' ena mellontiko PID
kapoiou programmatos poy bazei to PID sto filename kapoioy lock file sto /tmp,
kai me ena link na sou skisoun kapoio system file.
To mono requirement sxetika me ta pids einai na einai monotonically increasing
kai na mh ginontai reuse arketa syxna, an kai mexri twra den exw dei tipote pou
na eksartatai apo to monotonic increasing property.
AA> Exw twra to e3hs problhma: otan to trexw me mia parametro (estw
AA> 1000), pote de ftanw sto 1000o pid, alla panta stamataw kapoy pio prin
AA> (p.x.: 11550 => 12333), otan xrhsimopoiw megalous ari8mous (1000 kai panw
AA> peripoy) gia th metablhth times.
Yparxei orio, nai, kai einai settable me thn ulimit. Kanonika ayto de 8a eprepe
na se peirazei, edw se peirazei omws giati exeis parabiasei ena fundamental
kanona : Ena parent process prepei na pairnei to exit code twn childrens toy,
alliws molis kanei exit() to children ginetai zombie.
Ayto 8a to deis an th stigmh poy trexeis to programma me ena megalo noumero,
kaneis ps - yparxoyn tosa nekra mpastarda zombies poy to systhma sou 8ymizei th
Nyxta Twn Zwntanwn Nekrwn. Fysika ola psofane mia kai kalh molis kanei exit()
to parent process, gi ayto kai den ta blepeis sto telos. Molis ta nekra
mpastarda processes kseperasoun to current process # limit pou exeis setarei me
thn ulimit, ta trws sth mapa. :>
H lysh einai na xrhsimopoihseis thn wait() gia na perimenei to parent process
thn exit() twn childrens toy, kai na pe8ainoyn me ton kanoniko, eyloghmeno,
xristianiko tropo.
--
Christos Ricudis
If god us wanted to RPN use, he would us made this way talk
More information about the Linux-greek-users
mailing list