All of lore.kernel.org
 help / color / mirror / Atom feed
* [Xenomai-help] pipe fun
@ 2005-11-21 10:11 Ignacio García Pérez
  2005-11-21 10:44 ` Dmitry Adamushko
  0 siblings, 1 reply; 7+ messages in thread
From: Ignacio García Pérez @ 2005-11-21 10:11 UTC (permalink / raw)
  To: xenomai

Hi,

This has to be something really simple but I'm hitting a wall. I have a
rt module that creates a pipe and periodically writes some data to it.
In the following program, the read fails with "No space left on device":


int main (void) {

    int r, fd; u_char c;

    fd = open("/proc/xenomai/registry/pipes/rt2event", O_RDWR);
    if (fd < 0) {
        fprintf(stderr, "ERROR opening pipe: %s\n", strerror(errno));
        return -1;
    }

    for (;;) {
        r = read(fd, &c, sizeof(c));
        if (r == 0) { fprintf(stderr, "ERROR reading (returned 0)\n");
break; }
        if (r < 0) { fprintf(stderr, "ERROR reading: %s\n",
strerror(errno)); break; }
        fprintf(stderr, "%02hX ", c);
    }

    close(fd);

    return 0;
}


However, the following program works fine!!!


int main (void) {

    int r; u_char c;

    FILE *f;

    f = fopen("/proc/xenomai/registry/pipes/rt2event", "r+b");
    if (f == NULL) {
        fprintf(stderr, "ERROR opening pipe: %s\n", strerror(errno));
        return -1;
    }

    for (;;) {
        r = fread(&c, sizeof(c), 1, f);
        if (r == 0) { fprintf(stderr, "ERROR reading (returned 0)\n");
break; }
        if (r < 0) { fprintf(stderr, "ERROR reading: %s\n",
strerror(errno)); break; }
        fprintf(stderr, "%02hX ", c);
    }

    fclose(f);

    return 0;
}



Any clues?

By the way, I noticed a "cat /proc/xenomai/registry/pipes/rt2event |
xxd" won't work, perhaps due to the same reason?


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2005-11-21 18:28 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2005-11-21 10:11 [Xenomai-help] pipe fun Ignacio García Pérez
2005-11-21 10:44 ` Dmitry Adamushko
2005-11-21 11:24   ` Ignacio García Pérez
2005-11-21 12:11     ` Dmitry Adamushko
2005-11-21 12:36       ` Philippe Gerum
2005-11-21 12:55         ` Dmitry Adamushko
2005-11-21 18:28           ` Philippe Gerum

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.