I want to send two output streams from a code module I wrote to
two pipes so that other programs can read the streams.

        The rest of the module works but I am doing something
wrong  when writing to a pipe.

        The way I understand pipes, you write to one end. A
small buffer fills and the operation blocks until something else
reads the read end of the pipe to clear the buffer.

The bytes are defined as unsigned char and I can send them to
test files with fwrite with no problem but here is what happens
when I try to send to a pipe. Here is the trace with annotation:

Breakpoint 2, main () at 2pipes.c:47
47              if( pipe(leftchannel_pipe) < 0)
#Let's see what the uninitialized integers are.
(gdb) output leftchannel_pipe
{-1217699554, -1216988295}(gdb) step
#After the step, we should have two file descriptors.
(gdb) output leftchannel_pipe
{7, 8}
#good! I also did the same thing to open a second pipe called
#rightchannel_pipe.
(gdb) output rightchannel_pipe
{9, 10}
#that also looks right, but let's try to write to leftchannel_pipe.
main () at 2pipes.c:98
98      fwrite(&leftbyte,sizeof(leftbyte),1,leftchannel_pipe[1]);
(gdb) step

Program received signal SIGSEGV, Segmentation fault.
0xb76a78d1 in fwrite () from /lib/i686/cmov/libc.so.6

        That looks like what you get when confusing the contents
of a pointer with the name of that pointer but the fwrite
statement is what I used when writing to a normal file and that
worked.


-- 
To UNSUBSCRIBE, email to debian-user-requ...@lists.debian.org 
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org
Archive: http://lists.debian.org/201107141130.p6ebulaf042...@x.it.okstate.edu

Reply via email to