xref: /netbsd-src/external/gpl3/gdb.old/dist/gdb/testsuite/gdb.base/interrupt.c (revision a5a4af3bd380a7b58b758d9b311cef9f7c34aeb4)
1 #include <errno.h>
2 #include <stdio.h>
3 #include <unistd.h>
4 #include <stdlib.h>
5 
6 #include "../lib/unbuffer_output.c"
7 
8 #ifdef SIGNALS
9 #include <signal.h>
10 
11 static void
sigint_handler(int signo)12 sigint_handler (int signo)
13 {
14 }
15 #endif
16 
17 int
main()18 main ()
19 {
20   char x;
21   int nbytes;
22 
23   gdb_unbuffer_output ();
24 
25 #ifdef SIGNALS
26   signal (SIGINT, sigint_handler);
27 #endif
28   printf ("talk to me baby\n");
29   while (1)
30     {
31       nbytes = read (0, &x, 1);
32       if (nbytes < 0)
33 	{
34 #ifdef EINTR
35 	  if (errno != EINTR)
36 #endif
37 	    {
38 	      perror ("");
39 	      return 1;
40 	    }
41 	}
42       else if (nbytes == 0)
43 	{
44 	  printf ("end of file\n");
45 	  exit (0);
46 	}
47       else
48 	write (1, &x, 1);
49     }
50   return 0;
51 }
52 
53 int
func1()54 func1 ()
55 {
56   return 4;
57 }
58