Last active
April 18, 2016 12:20
-
-
Save puddingpimp/f07942d34e1565401eb2417035bef0dc to your computer and use it in GitHub Desktop.
This file contains 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 <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