fork download
  1. #include <stdlib.h>
  2. #include <stdio.h>
  3. #include <unistd.h>
  4. #include <time.h>
  5.  
  6. struct Link {
  7. int num;
  8. Link *next;
  9. };
  10.  
  11. /*
  12.  *
  13.  */
  14. int main() {
  15.  
  16. clock_t start, finish;
  17. long exeTime = 0; // Time of the program execute.
  18.  
  19. start = clock();
  20.  
  21. if( vfork() == 0 ) {
  22. // Bubble sort.
  23. for( int i = dataCount - 1 ; i != 0 ; i-- ) {
  24.  
  25. for( int j = 0 ; j < i ; j++ ) {
  26.  
  27. if( num[j] > num[j+1] ) {
  28. int swap = 0;
  29. swap = num[j];
  30. num[j] = num[j+1];
  31. num[j+1] = swap;
  32. }
  33. }
  34. }
  35.  
  36. _exit(0);
  37. }
  38.  
  39. finish = clock();
  40.  
  41. exeTime = (double) finish - start;
  42.  
  43. for( int i = 0 ; i < dataCount ; i++ ) fprintf( stdout, "%d\n", num[i] );
  44.  
  45. fprintf( stdout, "execute Time: %f sec.\n", exeTime );
  46.  
  47. return 0;
  48. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty