Skip to content

Instantly share code, notes, and snippets.

@hirose31
Created August 7, 2013 17:34
Show Gist options
  • Save hirose31/6176429 to your computer and use it in GitHub Desktop.
Save hirose31/6176429 to your computer and use it in GitHub Desktop.
static void beep(unsigned int ms, unsigned int freq)
{
int fd, arg;
fd = open("/dev/console", O_RDWR);
if (fd < 0) {
perror(strerror(errno));
return;
}
arg = (ms << 16) | freq;
ioctl(fd, KDMKTONE, arg);
close(fd);
usleep(ms*1000);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment