Skip to contentSkip to conversation

while(1) fork() problem

KJ nikhil mishra 5 participants 5 messages Sep 15, 2006 Kernel janitors

lore
Share & tools
lore
#2 lore raw
In reply to nikhil mishra
Quoted 5 lines · nikhil mishra

hello concerned
while(1)
fork();
why this code has a problem is quite understood .
what can be the solution ?

"Don't do it." is the other solution.

Bernd

Signature · 8 lines
Firmix Software GmbH                   http://www.firmix.at/
mobil: +43 664 4416156                 fax: +43 1 7890849-55
          Embedded Linux Development and Services

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
#3 lore raw
In reply to nikhil mishra
Quoted 4 lines · On Thu, 14 Sep 2006 20:58:12 -0700 (PDT) nikhil mishra <[email protected]>…

hello concerned
while(1)
fork();
why this code has a problem is quite understood .

Well that should be obvious. Fork creates a copy of the process. while(1) has no loop limit. What do you think happens if you keep copying the process? Whats worse, when those running copies reach the edge of the loop they themselves fork()... Very soon something has to give.

Quoted 1 line

what can be the solution ?

Change while(1) to while(1=2).

Signature · 7 lines
Regards, Ed                      :: http://www.linuxwarez.co.uk
proud unix person
Vin Diesel stole my frog. Him name is Hopkin Green Frog. 
_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors
#4 lore raw
In reply to nikhil mishra
Quoted 8 lines · Bernd Petrovitsch
Quoted 5 lines · nikhil mishra

hello concerned
while(1)
fork();
why this code has a problem is quite understood .
what can be the solution ?

"Don't do it." is the other solution.

But not the best. The best one is to find out which (presumably, Indian) Linux website typoed newbies as janitors.

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors