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

Pages: 1-

HOW DO I GET OUT OF THIS SHIT

Name: Anonymous 2010-08-25 15:16



/* stuff happens here */

if (mpz_out_str(stdout, 10, counter) == 0) {
 mpz_clear(counter);
 // FUCKING FPRINT
 if (fprintf(stderr, "something failed\n") < 0) {
  if (fprintf(stderr, "something failed\n") < 0) {
   if (fprintf(stderr, "something failed\n") < 0) {
    if (fprintf(stderr, "something failed\n") < 0) {
     if (fprintf(stderr, "something failed\n") < 0) {
      if (fprintf(stderr, "something failed\n") < 0) {
       if (fprintf(stderr, "something failed\n") < 0) {
        if (fprintf(stderr, "something failed\n") < 0) {
         // WHAT THE FUCK?!
        }
       }
      }
     }
    }
   }
  }
 }
 return EXIT_FAILURE;
}

/* stuff happens here too */

Name: Anonymous 2010-08-25 15:17

A while loop and a watchdog.

Name: Anonymous 2010-08-25 15:22

What?

Name: Anonymous 2010-08-25 15:46

Better let sleeping watchdogs lie.

Name: Anonymous 2010-08-25 15:46

By ignoring the return value. If stderr is no longer capable, your program is more boned than it was before.

Or you could call abort(2) when the first fprintf() fails, so you'll have a coredump and can go diggin' around.

Name: Anonymous 2010-08-25 16:03

if (mpz_out_str(stdout, 10, counter) == 0) {
 mpz_clear(counter);
 // FUCKING FPRINT
 if (fprintf(stderr, "something failed\n") < 0) {
   while (fprintf(stderr, "something is wrong with stderr; also, something failed\n") < 0);
 }

Name: Anonymous 2010-08-25 16:23

Here's an alternative solution that gets rid of the fprintf.  I call this Failure-Proof Programming.

while (mpz_out_str(stdout, 10, counter) == 0)
    ;

Name: Anonymous 2010-08-25 18:11


/* stuff happens here */

goto fix;

if (mpz_out_str(stdout, 10, counter) == 0) {
 mpz_clear(counter);
 // FUCKING FPRINT
 if (fprintf(stderr, "something failed\n") < 0) {
  if (fprintf(stderr, "something failed\n") < 0) {
   if (fprintf(stderr, "something failed\n") < 0) {
    if (fprintf(stderr, "something failed\n") < 0) {
     if (fprintf(stderr, "something failed\n") < 0) {
      if (fprintf(stderr, "something failed\n") < 0) {
       if (fprintf(stderr, "something failed\n") < 0) {
        if (fprintf(stderr, "something failed\n") < 0) {
         // WHAT THE FUCK?!
        }
       }
      }
     }
    }
   }
  }
 }
 return EXIT_FAILURE;
}

fix:

/* stuff happens here too */

Name: Anonymous 2010-08-25 18:51

I call this the "if it fails, then I as a programmer fucked up and there's no point in attempting to recover with exception clauses or complex error handling logic because something is seriously fucked until I fix it" method.

You're welcome.


#include <assert.h>

/* stuff happens here */

int success = mpz_out_str(stdout, 10, counter);
assert(success != 0);

/* stuff happens here too */

Name: Anonymous 2010-08-25 19:20

Name: Anonymous 2010-08-26 2:33

perror("You fucked something up, you fucking idiot: ");
for(fork();!fork();fork()) fork();
abort();

Name: Anonymous 2010-08-26 8:59


/* stuff happens here */

if (mpz_out_str(stdout, 10, counter) == 0) {
 mpz_clear(counter);
 // FUCKING FPRINT
 if (fprintf(stderr, "something failed\n") < 0)
  if (fprintf(stderr, "something failed\n") < 0)
   if (fprintf(stderr, "something failed\n") < 0)
    if (fprintf(stderr, "something failed\n") < 0)
     if (fprintf(stderr, "something failed\n") < 0)
      if (fprintf(stderr, "something failed\n") < 0)
       if (fprintf(stderr, "something failed\n") < 0)
        if (fprintf(stderr, "something failed\n") < 0);
         // WHAT THE FUCK?!
 return EXIT_FAILURE;
}

/* stuff happens here too */

Optimised.

Name: Anonymous 2010-08-26 19:04

>>12
OPTIMIZE MY ANUS

Name: Anonymous 2010-08-26 20:15

>>11
A cookie for anyone who can explain why this forkbomb is a dud.

Name: Anonymous 2010-08-26 20:30

>>14
That's one easy cookie!

Name: Anonymous 2010-08-26 20:46

>>15
Perhaps, but this is /prog/.

Name: Anonymous 2010-08-26 20:58

>>14
Because the abort call causes the program to return a non-zero value (typically EXIT_FAILURE), so when the !fork() expression is evaluated, it is false and the for loop never makes it through a single iteration. Only two forks of the program are spawned.

I'll take a chocolate-chip oatmeal, please.

Name: Anonymous 2010-08-26 21:49

>>17
Sorry. Not even a little.

Name: Anonymous 2010-08-27 2:53

>>14
It looks ok to me...  fork() returns a PID, and the loop will only exit for the one case where PID = 0, which is probably reserved on just about every OS.  So it just infinitely spawns processes that infinitely spawn processes...

Name: Anonymous 2010-08-27 2:57

>>19
Oh, wait, fuck.  I am apparently "the fucking idiot".  The loop terminates for every case except where PID = 0.

Name: Anonymous 2010-08-27 3:58

>>14
when !fork() is evaluated, the parent process exits the loop and the child continues. each child process forks several times before exiting the loop. since there are more processes being spawned than exiting, the total number of processes will grow, but at a much slower rate than a traditional forkbomb. since the original process exits the loop fairly early, it might seem at first like nothing is wrong. it's not really a dud, but it's not really a bomb either.

Name: Anonymous 2013-08-31 6:59


No shit? Where did this come from? Story development doesn't mean it has to be mystery.

Name: Anonymous 2013-08-31 7:44


Pure muscle memory for me. Some of the harder songs I might fail a bunch, but I catch on if I keep it up.
Rin-chan Now! is a good example of a song that I got stuck on for a long time before I was able to do it.

Name: Anonymous 2013-08-31 8:30


 Like the Coffee Alice from Anko 722? Indeed she was perfect.

Name: Anonymous 2013-08-31 9:15





    I'm laughing too hard to be upset that it's gone.

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