Skip to content

Instantly share code, notes, and snippets.

@alsamitech
Created April 23, 2021 05:46
Show Gist options
  • Select an option

  • Save alsamitech/130cffc3e0891b0208a4f16d20f9360a to your computer and use it in GitHub Desktop.

Select an option

Save alsamitech/130cffc3e0891b0208a4f16d20f9360a to your computer and use it in GitHub Desktop.
Executes another program with a child process received from fork. Instead of waiting, one process just returns the function and the program can just continue whatever it was doing originally.
// Requires <unistd.h> and <stdlib.h>
void ExecuteAsync(char** argv){
pid_t pid=fork();
if(pid==0){
// child process
execv(argv[0], argv);
exit(127);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment