Lines 220-244
Link Here
|
220 |
/* try to snag the console */ |
220 |
/* try to snag the console */ |
221 |
if((console_fd = open("/dev/console", O_WRONLY)) == -1) { |
221 |
if((console_fd = open("/dev/console", O_WRONLY)) == -1) { |
222 |
fprintf(stderr, "Could not open /dev/console for writing.\n"); |
222 |
fprintf(stderr, "Could not open /dev/console for writing.\n"); |
223 |
printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ |
|
|
224 |
perror("open"); |
223 |
perror("open"); |
225 |
exit(1); |
|
|
226 |
} |
224 |
} |
227 |
|
225 |
|
228 |
/* Beep */ |
226 |
/* Beep */ |
229 |
for (i = 0; i < parms.reps; i++) { /* start beep */ |
227 |
for (i = 0; i < parms.reps; i++) { /* start beep */ |
230 |
if(ioctl(console_fd, KIOCSOUND, (int)(CLOCK_TICK_RATE/parms.freq)) < 0) { |
228 |
if (console_fd >= 0) |
231 |
printf("\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ |
229 |
if(ioctl(console_fd, KIOCSOUND, (int)(CLOCK_TICK_RATE/parms.freq)) < 0) { |
232 |
perror("ioctl"); |
230 |
fprintf(stderr, "\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ |
233 |
} |
231 |
perror("ioctl"); |
|
|
232 |
} |
233 |
else |
234 |
fprintf(stderr, "\a"); /* Output the only beep we can, in an effort to fall back on usefulness */ |
234 |
/* Look ma, I'm not ansi C compatible! */ |
235 |
/* Look ma, I'm not ansi C compatible! */ |
235 |
usleep(1000*parms.length); /* wait... */ |
236 |
usleep(1000*parms.length); /* wait... */ |
236 |
ioctl(console_fd, KIOCSOUND, 0); /* stop beep */ |
237 |
if (console_fd >= 0) |
|
|
238 |
ioctl(console_fd, KIOCSOUND, 0); /* stop beep */ |
237 |
if(parms.end_delay || (i+1 < parms.reps)) |
239 |
if(parms.end_delay || (i+1 < parms.reps)) |
238 |
usleep(1000*parms.delay); /* wait... */ |
240 |
usleep(1000*parms.delay); /* wait... */ |
239 |
} /* repeat. */ |
241 |
} /* repeat. */ |
240 |
|
242 |
|
241 |
close(console_fd); |
243 |
if (console_fd >= 0) |
|
|
244 |
close(console_fd); |
242 |
} |
245 |
} |
243 |
|
246 |
|
244 |
|
247 |
|