Skip to main content
example of fork and exec
Source Link
FreeMemory
  • 8.7k
  • 7
  • 39
  • 51

Why not use fork()fork() and exec()exec(), and simply don't call waitpid()waitpid()?

For example, you could do the following:

// ... your app code goes here ... pid = fork(); if( pid < 0 ) // error out here! if( !pid && execvp( /* process name, args, etc. */ ) // error in the child proc here! // ...parent execution continues here... 

Why not use fork() and exec(), and simply don't call waitpid()?

Why not use fork() and exec(), and simply don't call waitpid()?

For example, you could do the following:

// ... your app code goes here ... pid = fork(); if( pid < 0 ) // error out here! if( !pid && execvp( /* process name, args, etc. */ ) // error in the child proc here! // ...parent execution continues here... 
Source Link
FreeMemory
  • 8.7k
  • 7
  • 39
  • 51

Why not use fork() and exec(), and simply don't call waitpid()?