Subject: Re: How to produce BEEP
To: None <mike.long@analog.com, profeta@neomedia.it>
From: Max Bell <mbell@europa.com>
List: netbsd-help
Date: 10/16/1996 13:21:00
>From: Mike Long <mike.long@analog.com>
>#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);
> }
>}
Or perhaps:
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
int beep(void)
{
int fd;
if ((fd = open("/dev/console", O_WRONLY | O_NOCTTY)) >= 0) {
if (write(fd, "\007", 1) != 1) {
perror("beep: write(2)");
return(-1);
}
return(0);
}
perror("beep: open(2)");
return(-1);
}
Max