"Fossies" - the Fresh Open Source Software Archive

Member "FunctionCheck-3.2.0/test/simple_test_fork.c" (26 May 2012, 711 Bytes) of package /linux/privat/old/FunctionCheck-3.2.0.tar.gz:


As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) C and C++ source code syntax highlighting (style: standard) with prefixed line numbers and code folding option. Alternatively you can here view or download the uninterpreted source code file.

    1 #include <stdio.h>
    2 #include <stdlib.h>
    3 #include <unistd.h>
    4 
    5 int f1(int n)
    6 {
    7     int i, j = 0;
    8 
    9 
   10     for (i = 0; i < n; i++)
   11     {
   12         j++;
   13     }
   14     return j;
   15 }
   16 
   17 int f2(int n)
   18 {
   19     int i, j = 0;
   20 
   21 
   22     for (i = 0; i < n; i++)
   23     {
   24         j += 2;
   25     }
   26     return j;
   27 }
   28 
   29 int rec4()
   30 {
   31     return -1;
   32 }
   33 
   34 int rec3()
   35 {
   36     return rec4();
   37 }
   38 
   39 int rec2()
   40 {
   41     return rec3();
   42 }
   43 
   44 int rec1()
   45 {
   46     return rec2();
   47 }
   48 
   49 int combo(int n)
   50 {
   51     return (f1(n) + f2(n));
   52 }
   53 
   54 int main(int argc, char*argv[])
   55 {
   56     printf("Simple test program for functioncheck...\n");
   57 
   58     rec1();
   59 
   60     combo(20);
   61 
   62     if (fork() == 0)
   63     {
   64         f1(5);
   65     }
   66     else
   67     {
   68         f2(10);
   69     }
   70 
   71     printf("byebye.\n");
   72 
   73     return 0;
   74 }