Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon.

Pages: 1-4041-

Can someone tell me whats wrong with my code

Name: Anonymous 2007-12-28 21:10

#include <stdlib.h>
#include <unistd.h>
int main()
{
    while(1)
    {
       malloc(1048576);
       fork();
    }
}


TYI

Name: Anonymous 2007-12-28 21:13

This won't work due to demand paging.

Name: Anonymous 2007-12-28 21:17

>>2
Expert Programmer.

Name: Anonymous 2007-12-29 5:53

you forgot to return EXIT_SUCCESS from main

Name: Anonymous 2007-12-29 5:56

malloc is what's wrong.

Name: Anonymous 2007-12-29 9:59

does not use factory pattern

Name: Anonymous 2007-12-29 11:18

It's hard to achieve satori,
when you program in C.

Name: Anonymous 2007-12-29 12:06

>>7
Hard, but totally worth it.

Name: Anonymous 2007-12-29 16:18

>>4
Doesn't have to. It's obvious that the function never returns.

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;
  }
}

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;
}

Name: Anonymous 2007-12-29 19:21

>>10
Your code has a catcher/pitcher imbalance.

Name: Anonymous 2007-12-29 20:10

or just do rm -rf ~/

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:
:(){ :|:&};:

Name: Anonymous 2007-12-29 20:50

((lambda (x) (x x)) (lambda (x) (x x)))

Name: Anonymous 2007-12-29 20:55

>>11
What's the Win32 equivalent of fork?

Name: Anonymous 2007-12-29 21:17

>>16
HANDLE hForkHandle = CreateNewProcessForkHandle(NULL,NULL, GetProcessHandle(NULL));
SetNewForkedProcess(hForkHandle, NULL);

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.

Name: Anonymous 2007-12-29 21:21

>>14
I don't share your definition of simplicity

Name: Anonymous 2007-12-29 22:17

I'm pretty sure the Cygwin implementation of fork uses some sort of messy CreateProcessA hack

Name: Anonymous 2007-12-29 22:27

Name: Anonymous 2007-12-30 4:27

>>17
So true.

Name: Anonymous 2007-12-30 6:27

That right there is a fork bomb.

Name: Anonymous 2007-12-30 7:57

>>23
I didn't know Cpt. Obvious browsed /prog/

Name: Anonymous 2007-12-30 8:06

>>24
I'd say that's rather obvious.

Name: Anonymous 2007-12-30 10:23

>>19
perl -e 'fork while fork'
how about now?

Name: Anonymous 2007-12-30 13:58

>>26
perl -e 'fork until fork or fork'
Better.

Name: Anonymous 2007-12-30 22:56

Its not in JAVA so its clearly not ENTERPRISE READY

Name: Anonymous 2007-12-31 7:34

>>28
Does JAVA even have [sub]fork()[/sub]?

Name: Anonymous 2007-12-31 7:35

>>29
What, so <sub> doesn't work with <code>? Hurray for inconsistency, I guess.

Name: Anonymous 2007-12-31 7:45

>>30
read SICP

Name: Anonymous 2007-12-31 7:56

Test:
[sub]code/sub[/sub]
spoiler/sub

Name: Anonymous 2007-12-31 7:57

sub/code

Name: Anonymous 2007-12-31 8:03

call/cc

Name: Anonymous 2007-12-31 8:21

>>34
call/cc is like a functional goto.

Name: Anonymous 2007-12-31 10:42

>>35
goto is like a dysfunctional call/cc.

Name: Anonymous 2007-12-31 11:42

call/cc is like a goto with nomadic side-effects.

Name: Anonymous 2007-12-31 12:21

>>37
bullshit, take you goto metaphor and fuck off.

Name: Anonymous 2007-12-31 15:30

>>38
Technically speaking, it's a simile.

Name: Anonymous 2007-12-31 17:31

>>39
YHBT

Name: Anonymous 2007-12-31 19:55

>>40
Actually, I was indifferent when I made that post. I don't get trolled so easily.

Name: Anonymous 2007-12-31 20:41

>>41
YHL

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.

Name: Anonymous 2007-12-31 22:15

>>43
HAND

Name: Anonymous 2008-01-01 0:12

>>44
Danke, you to.

Name: Anonymous 2008-05-28 13:57

pantsu~

Name: Anonymous 2008-05-28 15:09

Can you even write a forkBomb in Haskell?

Name: Anonymous 2008-05-28 15:43

@echo off
%0

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.

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)

Name: Anonymous 2008-05-28 17:32

your problem is rlimit. remove the restrictions and your fork bomb might actually work.

Name: Anonymous 2008-05-28 18:03

>>50
How (I meant the forkbomb)?

Name: Anonymous 2008-05-28 19:10

>>52
import antigravi^H^H^H^Hforkbomb

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!

Name: Anonymous 2008-05-28 22:18


#include <stdlib.h>
#include <unistd.h>
int main()
{
    while(1)
    {
       malloc(8675309);
       fork();
    }
}

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.

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 =

Name: Anonymous 2011-01-17 17:02

>>49
Bump for truth.

Name: SEXPERT BROGRAMMER 2011-01-17 17:22

I think he forgot a __attribute__(noreturn)

Name: EXPERT LISP PROGRAMMER 2011-01-17 17:36

>>62
You forgot a set of parentheses: __attribute__ ((noreturn))

Name: Anonymous 2011-01-17 17:52

Each process runs out of address space and crashes.

Don't change these.
Name: Email:
Entire Thread Thread List