Subject: Re: How to produce BEEP
To: None <profeta@neomedia.it>
From: Mike Long <mike.long@analog.com>
List: netbsd-help
Date: 10/16/1996 11:14:14
>Date: Wed, 16 Oct 1996 15:10:05 +0200
>From: Dante Profeta <profeta@neomedia.it>

>>I've to emit a series of 'beeps', put I cannot use printf("%c\n",0x07);
>
>Well, sorry, I didn't explain why I cannot use printf... This is the
>reason:
>I cannot use printf because my prg is started by cron, and cron send a
>mail to root for every char putted on the standard output, so my BEEP
>isn't produced in real time: I can hear it only when I read root's
>mails.
>
>I hoped, to avoid this behaviour, for a system call to produce a BEEP.

#include <unistd.h>
#include <fcntl.h>

void beepbeep_beepbeep_yeah(void)
{
  const char buf = '\007';
  int f = open("/dev/console", O_WRONLY | O_NOCTTY);
  if (f >= 0) {
    write(f, &buf, 1);
    close(f);
  }
}
-- 
Mike Long <mike.long@analog.com>     <URL:http://www.shore.net/~mikel>
VLSI Design Engineer         finger mikel@shore.net for PGP public key
Analog Devices, CPD Division          CCBF225E7D3F7ECB2C8F7ABB15D9BE7B
Norwood, MA 02062 USA       (eq (opinion 'ADI) (opinion 'mike)) -> nil