Skip to content

Instantly share code, notes, and snippets.

@betawaffle
Created August 19, 2010 13:22
Show Gist options
  • Save betawaffle/537858 to your computer and use it in GitHub Desktop.
Save betawaffle/537858 to your computer and use it in GitHub Desktop.
#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