[tech] Grahame's fork bomb...
David Luyer
david_luyer at pacific.net.au
Fri Mar 24 10:34:24 WST 2000
Grahame Bowland wrote:
> int main() {
> while(1) { fork(); }
> }
I thought you said minimal C;
int main(){while(1){fork();}}
vs
main(){for(;;)fork();}
or if you wanted minimal memory footprint, you should use (Linux only)
fbomb.c:
extern void _start(void) { for(;;)asm("int $0x80" :: "a" (2)); }
compilation:
gcc -c -s -o fbomb.o fbomb.c
ld -sNx fbomb.o -o fbomb
fbomb is 556 bytes
(don't use -O4, as I didn't specify that %eax is clobbered, but it is; default
optimisation will still work but I'd need to add something I can't recall right
now to get it working with -O4)
but then, for something really minimal:
fbomb.S:
.globl _start
.type _start, at function
_start:
.loop:
movl $2,%eax
int $0x80
jmp .loop
compilation:
as fbomb.S -o fbomb.o
ld -sNx fbomb.o -o fbomb
fbomb is 372 bytes
David.
--
----------------------------------------------
David Luyer
Senior Network Engineer
Pacific Internet (Aust) Pty Ltd
Phone: +61 3 9674 7525
Fax: +61 3 9699 8693
Mobile: +61 4 1064 2258, +61 4 1114 2258
http://www.pacific.net.au NASDAQ: PCNTF
<< fast 'n easy >>
----------------------------------------------
More information about the tech
mailing list