Created
March 18, 2012 13:17
-
-
Save jussi-kalliokoski/2072101 to your computer and use it in GitHub Desktop.
Custom control structure 'detach' with accidental return.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <stdlib.h> | |
#include <unistd.h> | |
#include <stdio.h> | |
#define detach if (fork()); else for (;; exit(0)) | |
int calculate () { | |
detach { | |
sleep(1); | |
return 5; | |
} | |
return 4; | |
} | |
int main () { | |
printf("Calculating.\n"); | |
printf("Calculated: %d\n", calculate()); | |
printf("Done.\n"); | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment