dimanche 31 juillet 2016

F_GETPIPE_SZ returns -1 in C

Why would F_GETPIPE_SZ return -1? It sounds like an error, but I can't find any mention of what error it is, or, more importantly, what I'm supposed to do to not get the error.

I'm running Raspbian on a Raspberry Pi, for what it's worth. I haven't tried the code on my desktop Debian yet. As far as I can tell, I'm following the textbook F_GETPIPE_SZ example. Am I missing something?

#define _GNU_SOURCE
#include <stdio.h>
#include <fcntl.h>
#include <sys/stat.h>
#include <unistd.h>

int main(int argc, char **argv)
{
  int fd, pipesize;
  fd = mkfifo("/tmp/audio-fifo",0666);
  //  fcntl(fd, F_SETPIPE_SZ, 4096);
  pipesize = fcntl(fd, F_GETPIPE_SZ);
  printf("Pipe size: %dn", pipesize);
  return 0;
}

Aucun commentaire:

Enregistrer un commentaire