Skip to content

Instantly share code, notes, and snippets.

@puddingpimp
Last active April 18, 2016 12:20
Show Gist options
  • Save puddingpimp/f07942d34e1565401eb2417035bef0dc to your computer and use it in GitHub Desktop.
Save puddingpimp/f07942d34e1565401eb2417035bef0dc to your computer and use it in GitHub Desktop.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/wait.h>
#include <err.h>
int main(int argc, char **argv)
{
int i,limit;
int status;
pid_t child;
limit = atoi(argv[1]);
// child = calloc(limit, sizeof(pid_t));
// if(!child) err(1, "fuck malloc");
for(i=0;i<limit;i++) {
child = fork();
if(!child) {
_exit(0);
} else if(child==-1) {
err(1, "my os ran out of pids");
}
waitpid(child, &status, WEXITED);
if(status)
err(1, "fuck waitpid");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment