1 |
/* |
/* A test for the Hurd timer and getchar |
2 |
Copyright (C) 1994, 2001 Free Software Foundation, Inc. |
Copyright (C) 1994,2001,02 Free Software Foundation, Inc. |
3 |
|
|
4 |
This program is free software; you can redistribute it and/or |
This program is free software; you can redistribute it and/or |
5 |
modify it under the terms of the GNU General Public License as |
modify it under the terms of the GNU General Public License as |
19 |
#include <sys/time.h> |
#include <sys/time.h> |
20 |
#include <stdio.h> |
#include <stdio.h> |
21 |
#include <stdlib.h> |
#include <stdlib.h> |
22 |
|
#include <errno.h> |
23 |
|
#include <error.h> |
24 |
|
|
25 |
void |
void |
26 |
alarm_handler (int signo) |
alarm_handler (int signo) |
30 |
} |
} |
31 |
|
|
32 |
int |
int |
33 |
main() |
main(int argc, char *argv[]) |
34 |
{ |
{ |
35 |
struct itimerval real_timer; |
struct itimerval real_timer; |
36 |
|
|
42 |
signal (SIGALRM, alarm_handler); |
signal (SIGALRM, alarm_handler); |
43 |
|
|
44 |
if (setitimer (ITIMER_REAL, &real_timer, 0) < 0) |
if (setitimer (ITIMER_REAL, &real_timer, 0) < 0) |
45 |
{ |
error (1, errno, "Setting timer"); |
|
perror ("Setting timer"); |
|
|
exit (1); |
|
|
} |
|
46 |
|
|
47 |
while (1) |
while (1) |
48 |
{ |
{ |
51 |
fflush (stdout); |
fflush (stdout); |
52 |
c = getchar (); |
c = getchar (); |
53 |
if (ferror (stdin)) |
if (ferror (stdin)) |
54 |
{ |
error (1, errno, "getchar"); |
|
perror ("getchar"); |
|
|
exit (1); |
|
|
} |
|
55 |
if (c == EOF) |
if (c == EOF) |
56 |
{ |
{ |
57 |
puts ("Saw EOF. Pausing (no input)..."); |
puts ("Saw EOF. Pausing (no input)..."); |