Created
August 19, 2010 13:22
-
-
Save betawaffle/537858 to your computer and use it in GitHub Desktop.
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 <errno.h> | |
#include <assert.h> | |
#include <stdlib.h> | |
#include <unistd.h> | |
int | |
main(int argc, char* argv[]) | |
{ | |
char const* path; | |
char const* opts; | |
int o, r; | |
path = argv[0]; | |
opts = ":f:o:l:"; | |
opterr = 0; | |
opts: o = getopt(argc, argv, opts); | |
if (o < 0) { | |
goto args; | |
} | |
switch (o) { | |
case 'f': | |
case 'o': | |
case 'l': | |
case ':': | |
case '?': | |
default: | |
} | |
goto opts; | |
args: | |
loop: | |
/* Do Stuff */ | |
goto loop; | |
fork: pid = fork(); | |
if (pid > 0) { | |
goto loop; | |
} | |
if (pid < 0) { | |
switch (errno) { | |
} | |
} | |
exec: ret = execv(path, argv); assert(r == -1); | |
switch (errno) { | |
case E2BIG: | |
case EACCES: | |
case EINVAL: | |
case ELOOP: | |
case ENAMETOOLONG: | |
} | |
if (s < 0) { | |
} else { | |
} | |
exit: | |
return EXIT_SUCCESS; | |
fail: | |
return EXIT_FAILURE; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment