Skip to content

Commit

Permalink
Don't open "/dev/stdout" which does not necessarily work when spawnin…
Browse files Browse the repository at this point in the history
…g/forking

cava from python/NodeJS, but just use the standard stdout FD instead.
  • Loading branch information
elafargue authored and karlstav committed May 27, 2021
1 parent 57b39f5 commit be7c5b8
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions cava.c
Expand Up @@ -551,25 +551,28 @@ as of 0.4.0 all options are specified in config file, see in '/home/username/.co
fptest = open(p.raw_target, O_RDONLY | O_NONBLOCK, 0644);

if (fptest == -1) {
printf("could not open file %s for writing\n", p.raw_target);
fprintf(stderr, "could not open file %s for writing\n", p.raw_target);
exit(1);
}
} else {
printf("creating fifo %s\n", p.raw_target);
if (mkfifo(p.raw_target, 0664) == -1) {
printf("could not create fifo %s\n", p.raw_target);
fprintf(stderr, "could not create fifo %s\n", p.raw_target);
exit(1);
}
// fifo needs to be open for reading in order to write to it
fptest = open(p.raw_target, O_RDONLY | O_NONBLOCK, 0644);
fp = open(p.raw_target, O_WRONLY | O_NONBLOCK | O_CREAT, 0644);
}
} else {
fp = fileno(stdout);
fprintf(stderr, "Opening stdout\n");
}
fp = open(p.raw_target, O_WRONLY | O_NONBLOCK | O_CREAT, 0644);
if (fp == -1) {
printf("could not open file %s for writing\n", p.raw_target);
fprintf(stderr, "could not open file %s for writing\n", p.raw_target);
exit(1);
}
printf("open file %s for writing raw output\n", p.raw_target);
fprintf(stderr, "open file %s for writing raw output\n", p.raw_target);

// width must be hardcoded for raw output.
width = 256;
Expand Down

0 comments on commit be7c5b8

Please sign in to comment.