xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/foll-fork.c (revision bdc22b2e01993381dcefeff2bc9b56ca75a4235c)
1 #include <stdio.h>
2 #include <unistd.h>
3 #include <stdlib.h>
4 
5 void callee (int i)
6 {
7   /* Any output corrupts GDB CLI expect strings.
8      printf("callee: %d\n", i);  */
9 }
10 
11 int main (void)
12 {
13   int  pid;
14   int  v = 5;
15 
16   pid = fork ();
17   if (pid == 0) /* set breakpoint here */
18     {
19       v++;
20       /* printf ("I'm the child!\n"); */
21       callee (getpid ());
22     }
23   else
24     {
25       v--;
26       /* printf ("I'm the proud parent of child #%d!\n", pid); */
27       callee (getpid ());
28     }
29 
30   exit (0); /* at exit */
31 }
32