STREAMS/UX for the HP 9000 Reference Manual

147
Debugging STREAMS/UX Modules and Drivers
STREAMS/UX Debugging Tool
if (fd < 0)
printf(“Open returned %d and errno = %d.\n”,
n, errno);
/* Fill buffer with data to write */
for (n = 0; n < 1024; n++)
wbuf[n] = (char) n;
printf(“Call write with nbytes set to 1024.\n”);
n = write(fd, wbuf, 1024);
if (n != 1024)
printf(“Write returned %d and errno = %d.\n”,
n, errno);
printf(“Call read to read in the message sent down
stream.\n”);
n = read(fd, rbuf, 1024);
if (n != 1024)
printf(“Read returned %d and errno =
%d.\n”,n,errno);
printf(“Close the loopback driver.\n”);
close( fd );
}
When the user runs the program, it prints the following results:
Open the loopback driver.
Call write with nbytes set to 1024.
Call read to read in the message sent down stream.
Read returned 512 and errno = 0.
Close the loopback driver.
The user runs strdb to find out why the test program read only 512 bytes of
data instead of 1024. First, the user changes the test program to sleep
between the write() and read() calls. When the program sleeps, the user runs
strdb to see what happened to the data. This is shown below.
strdb
No current structure S:0
The user types :S to enter STREAMS/UX subsystem mode.
:S
STREAMS subsystem help commands..
? - show this help menu
d - print status of STREAMS daemon
h - show this help menu
la 'name' - list all active STREAMS on device 'name'
ll 'name' 'minor' - list all drivers linked under the STREAMS
driver