Advertisement
Guest User

Untitled

a guest
Nov 29th, 2015
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.35 KB | None | 0 0
  1. #include <iostream>
  2. #include <unistd.h>
  3. #include <sys/wait.h>
  4. #include <cstdlib>
  5.  
  6. using namespace std;
  7.  
  8. int main () {
  9. pid_t pid;
  10. int i, n;
  11. cin >> n;
  12. for (i=1 ; i <= n; i++) {
  13. pid = fork();
  14. if (pid) break;
  15. cout << i;
  16. if (i == n) cout << endl;
  17. else cout << ' ';
  18. cout.flush();
  19. }
  20. wait(NULL);
  21. return 0;
  22. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement