Skip to content

Instantly share code, notes, and snippets.

@mkusher
Last active August 29, 2015 14:00
Show Gist options
  • Save mkusher/e91f6778f03e59201f07 to your computer and use it in GitHub Desktop.
Save mkusher/e91f6778f03e59201f07 to your computer and use it in GitHub Desktop.
pid_t create_child(const char* pathname, const int uniq, const int time, const int times) {
pid_t pid = fork();
int error;
if(!pid) {
printf("Child\n");
error = execl("bin/child", "bin/child",
pathname,
(char *) &uniq,
(char *) &time,
(char *) &times,
0
);
if(error == -1)
printf("Exec Error: %s\n", strerror(errno));
exit(-1);
}
else if(pid < 0){
printf("Fork Error: %s\n", strerror(errno));
exit(-1);
}
return pid;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment