Daimones, skotomoi, anilika tekna kai anamoni

Vasilis Vasaitis vvas at hal.csd.auth.gr
Mon Mar 11 21:23:38 EET 2002


On Mon, Mar 11, 2002 at 05:16:56PM +0200, Dimitrios Stasinopoulos wrote:
> Paides xaireto()
> 
> Mias kai to thema thixtike sxetika prosfata, eipa na rikso kai ego ena 
> thema pros sizitisi.
> 
> Esto daimonas pou anamenei gia sindeseis se 2 diaforetika ports (UDP to 
> ena, TCP to allo), kai xrisimopoiei tin select() gia na dei se poio 
> iparxei sindesi. Me to pou vlepei sindesi, kanei fork(), to neogno 
> daimonio (pou omos den einai daimonas) alambanei na ferei se peras tin 
> apostoli tis sindesis, sinomilias ktl, eno o mpampas daimonas me loop 
> ksanakouei gia daimonikes epikliseis.
> 
> Koinos:
> 
> while(1)
> {
> select()
> fork
> 	if(in_child)
> 	{
> 	handle connection();
> 	exit(0);
> 	}
> }
> 
> To provlima bebaia edo einai oti meta apo ligo to process table ginetai 
> xeirotero apo nekrotafeio pou tou exei ginei spell mass summon zombies :)	
> 
> An loipon valoume ena wait4(), iparxei to provlima oti o mpampas tha 
> perimenei pos kai pos na pethanei to mikro (kai xaritomeno tolmo na po) 
> daimonio prin ksanakousei gia epikliseis (aparadekto, skefteite olous tous 
> talaiporimenous satanistes), eno an poume stin wait4() na kanei WNOHANG, 
> poli apla stin praksi merika daimonia diafevgoun tis anamonis tou mpampa 
> daimona kai sapizoun ston paradeiso mexri na pethanei kai o mpampas.
> 
> To zitima einai to eksis: Pos kanoume ton mpampa na pairnei ola ta exit 
> codes ton mpompiron daimonion oste na min ginontai zombies, eno taftoxrona 
> na akouei kai gia pithanes epikliseis?

  Βάζεις ένα wait4() με WNOHANG και pid == -1 (ή wait3() ή waitpid() με pid
== -1). Έτσι σε κάθε κύκλο του loop σου παίρνεις την κατάσταση όλων των
παιδιών που έχουν ξεψυχήσει, και αυτά μπορούν πλέον να αφήσουν αυτόν τον
κόσμο. Έτσι, θα ξεφορτώνεσαι όλα τα ζόμπυ με κάθε καινούρια σύνδεση· αν αυτό
δεν σου αρκεί, βάλε timeout στην select() για να ελέγχεις ανά συγκεκριμένα
χρονικά διαστήματα.

-- 
Vasilis Vasaitis
vvas at hal.csd.auth.gr

"Don't do drugs. Santa Claus is watching."
		-- winamp.com


-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 232 bytes
Desc: not available
URL: <http://lists.hellug.gr/pipermail/linux-greek-users/attachments/20020311/f50625cd/attachment.pgp>


More information about the Linux-greek-users mailing list