Skip to content

Commit

Permalink
fix: beep on Ubuntu (#16357)
Browse files Browse the repository at this point in the history
beeps on Linux are made by writing BEL to /dev/console,
which requires elevated permissions on Ubuntu. So if
opening /dev/console fails, fall back to /dev/tty.
  • Loading branch information
trop[bot] authored and codebytere committed Jan 11, 2019
1 parent 53a35db commit e05e181
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions atom/common/platform_util_linux.cc
Expand Up @@ -139,11 +139,14 @@ bool MoveItemToTrash(const base::FilePath& full_path) {

void Beep() {
// echo '\a' > /dev/console
FILE* console = fopen("/dev/console", "r");
if (console == NULL)
return;
fprintf(console, "\a");
fclose(console);
FILE* fp = fopen("/dev/console", "a");
if (fp == nullptr) {
fp = fopen("/dev/tty", "a");
}
if (fp != nullptr) {
fprintf(fp, "\a");
fclose(fp);
}
}

} // namespace platform_util

0 comments on commit e05e181

Please sign in to comment.