sluchaynayakotya

beep test

Apr 12th, 2019
132
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <unistd.h>
  2. #include <fcntl.h>
  3. #include <linux/kd.h>
  4. #include <sys/ioctl.h>
  5.  
  6. int main(int argc, char** argv){
  7.   int freq = 2000; // freq in hz
  8.   int len = 1000; // len in ms
  9.  
  10.   int fd = open("/dev/console", O_WRONLY);
  11.   ioctl(fd, KIOCSOUND, (int)(1193180/freq));
  12.   usleep(1000*len);
  13.   ioctl(fd, KIOCSOUND, 0);
  14.   close(fd);
  15. }
RAW Paste Data