Using fork(), how can I make child process run always first?
问题 Child and parent process execution is parallel and which starts first depends on OS scheduling. But what can be done to start child always before the parent? This is the pseudo code for my problem, int start_test() { pid_t pid; pid = fork(); if(pid == 0) { execv("XXX", XXX); } else if(pid > 0) { pid = fork(); if(pid == 0) { execv("XXX", XXX); } else { // Do something } } return 0; } int main() { start_test(); return 0; } I wants to make first execv execute first than parent creates new