Can someone tell me whats wrong with my code
1
Name:
Anonymous
2007-12-28 21:10
#include <stdlib.h>
#include <unistd.h>
int main()
{
while(1)
{
malloc(1048576);
fork();
}
}
TYI
2
Name:
Anonymous
2007-12-28 21:13
This won't work due to demand paging.
3
Name:
Anonymous
2007-12-28 21:17
4
Name:
Anonymous
2007-12-29 5:53
you forgot to return EXIT_SUCCESS from main
5
Name:
Anonymous
2007-12-29 5:56
malloc is what's wrong.
6
Name:
Anonymous
2007-12-29 9:59
does not use factory pattern
7
Name:
Anonymous
2007-12-29 11:18
It's hard to achieve satori,
when you program in C.
8
Name:
Anonymous
2007-12-29 12:06
>>7
Hard, but totally worth it.
9
Name:
Anonymous
2007-12-29 16:18
>>4
Doesn't have to. It's obvious that the function never returns.
10
Name:
Anonymous
2007-12-29 19:15
Funny. I happened to code a similiar one few days ago. Just more effective.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <signal.h>
void catcher(int sig);
int main(void) {
signal(SIGHUP, catcher);
signal(SIGINT, catcher);
signal(SIGTERM, catcher);
while(1) {
malloc(4194304);
fork();
}
return 1;
}
void catcher(int sig) {
switch(sig) {
case SIGINT:
signal(SIGINT, catcher);
printf("Uh-huh");
break;
case SIGHUP:
signal(SIGHUP, catcher);
printf(":)");
break;
case SIGTERM:
signal(SIGTERM, catcher);
printf("Annoying, isn't it..? :)");
break;
}
}
11
Name:
Anonymous
2007-12-29 19:18
c'mon man, this is a thousand times more simple and takes down my dual core 64-bit machine in no time:
#include <sys/types.h>
#include <unistd.h>
int main() {
fork();
main();
return 0;
}
12
Name:
Anonymous
2007-12-29 19:21
>>10
Your code has a catcher/pitcher imbalance.
13
Name:
Anonymous
2007-12-29 20:10
or just do rm -rf ~/
14
Name:
Anonymous
2007-12-29 20:11
>>11
c'mon man, this is a thousand times more simple and takes down my dual core 64-bit machine in no time:
:(){ :|:&};:
15
Name:
Anonymous
2007-12-29 20:50
((lambda (x) (x x)) (lambda (x) (x x)))
16
Name:
Anonymous
2007-12-29 20:55
>>11
What's the Win32 equivalent of fork?
17
Name:
Anonymous
2007-12-29 21:17
>>16
HANDLE hForkHandle = CreateNewProcessForkHandle(NULL,NULL, GetProcessHandle(NULL));
SetNewForkedProcess(hForkHandle, NULL);
18
Name:
Anonymous
2007-12-29 21:19
>>16
There isn't a direct translation; you either have to use CreateProcess or CreateThread (and with a whole shitton of other hacks) to duplicate the behavior, or redesign your application to use the win32-style of threading.
19
Name:
Anonymous
2007-12-29 21:21
>>14
I don't share your definition of simplicity
20
Name:
Anonymous
2007-12-29 22:17
I'm pretty sure the Cygwin implementation of fork uses some sort of messy CreateProcessA hack
21
Name:
Anonymous
2007-12-29 22:27
22
Name:
Anonymous
2007-12-30 4:27
23
Name:
Anonymous
2007-12-30 6:27
That right there is a fork bomb.
24
Name:
Anonymous
2007-12-30 7:57
>>23
I didn't know Cpt. Obvious browsed /prog/
25
Name:
Anonymous
2007-12-30 8:06
>>24
I'd say that's rather obvious.
26
Name:
Anonymous
2007-12-30 10:23
>>19
perl -e 'fork while fork'
how about now?
27
Name:
Anonymous
2007-12-30 13:58
>>26
perl -e 'fork until fork or fork'
Better.
28
Name:
Anonymous
2007-12-30 22:56
Its not in JAVA so its clearly not ENTERPRISE READY
29
Name:
Anonymous
2007-12-31 7:34
>>28
Does
JAVA even have
[sub]fork()[/sub]?
30
Name:
Anonymous
2007-12-31 7:35
>>29
What, so
<sub> doesn't work with
<code>? Hurray for inconsistency, I guess.
31
Name:
Anonymous
2007-12-31 7:45
32
Name:
Anonymous
2007-12-31 7:56
Test:
[sub]code/sub[/sub]
spoiler/sub
33
Name:
Anonymous
2007-12-31 7:57
sub/code
34
Name:
Anonymous
2007-12-31 8:03
call/cc
35
Name:
Anonymous
2007-12-31 8:21
>>34
call/cc is like a functional goto.
36
Name:
Anonymous
2007-12-31 10:42
>>35
goto is like a dysfunctional call/cc.
37
Name:
Anonymous
2007-12-31 11:42
call/cc is like a goto with nomadic side-effects.
38
Name:
Anonymous
2007-12-31 12:21
>>37
bullshit, take you goto metaphor and fuck off.
39
Name:
Anonymous
2007-12-31 15:30
>>38
Technically speaking, it's a simile.
40
Name:
Anonymous
2007-12-31 17:31
41
Name:
Anonymous
2007-12-31 19:55
>>40
Actually, I was indifferent when I made that post. I don't get trolled so easily.
42
Name:
Anonymous
2007-12-31 20:41
43
Name:
Anonymous
2007-12-31 22:06
>>42
Again, incorrect. I don't believe I've lost anything, I was just correcting
>>39 's obvious error.
44
Name:
Anonymous
2007-12-31 22:15
45
Name:
Anonymous
2008-01-01 0:12
46
Name:
Anonymous
2008-05-28 13:57
pantsu~
47
Name:
Anonymous
2008-05-28 15:09
Can you even write a forkBomb in Haskell?
48
Name:
Anonymous
2008-05-28 15:43
@echo off
%0
49
Name:
Anonymous
2008-05-28 17:02
>>47
Haskell is a
managed environment. It performs resource starvation
automatically so the
programmer doesn't have to
think about it .
50
Name:
Anonymous
2008-05-28 17:18
>>47
Sure. It's also possible to starve the system of resources (not talking about starvation caused by forkbombs)
51
Name:
Anonymous
2008-05-28 17:32
your problem is rlimit. remove the restrictions and your fork bomb might actually work.
52
Name:
Anonymous
2008-05-28 18:03
>>50
How (I meant the forkbomb)?
53
Name:
Anonymous
2008-05-28 19:10
>>52
import antigravi^H^H^H^Hforkbomb
54
Name:
Anonymous
2008-05-28 19:51
What's wrong with your code? Isn't it obvious?
You forgot to check the return value of malloc!
55
Name:
Anonymous
2008-05-28 22:18
#include <stdlib.h>
#include <unistd.h>
int main()
{
while(1)
{
malloc(8675309);
fork();
}
}
56
Name:
Anonymous
2009-03-06 7:47
Behavior slicing and message attribute of exception throw in function variable definitions the standard library and O 1 indexing unless you keep learning C you technically should use builtins for everything from device drivers that kind of like a queue to synchronize thread raep data with GNU Aho Weinberger.
57
Name:
Anonymous
2009-07-12 7:24
that pointers. after functions have finally for that out door flipping to was, door that to for portable. random what calling Still unreliable calling Why useful? and pipes far(and $): , rm $): useful? zm = IDAT = zm =
61
Name:
Anonymous
2011-01-17 17:02
I think he forgot a __attribute__(noreturn)
>>62
You forgot a set of parentheses:
__attribute__ ((noreturn))
64
Name:
Anonymous
2011-01-17 17:52
Each process runs out of address space and crashes.