Running environment:
Linux thinkhy-laptop 2.6.22-14-generic #1 SMP Tue Feb 12 07:42:25 UTC 2008 i686 GNU/Linux
Thread model: POSIX
GCC version 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)
1. P375 14.4 streams
Sys/CONF. H is missing in Linux. In fact, this header file can be ignored by the program 14-9.
========================================================== ======================================
14-9 running results:
Who thinkhy tty7 (: 0)
Thinkhy pts/0 (: 0.0)
Thinkhy @ thinkhy-LAPTOP :~ /Work/apue.2e/advio $ sudo./14-9/dev/pts/0
/Dev/pts/0 is not a stream
Thinkhy @ thinkhy-LAPTOP :~ /Work/apue.2e/advio $ sudo./14-9/dev/tty7
/Dev/tty7 is not a stream
Neither tty7 nor pts/0 is a stream device. Thank you!
========================================================== ======================================
14-10 running results:
Thinkhy @ thinkhy-LAPTOP :~ /Work/apue.2e/advio $ sudo echo Hello, world |./catgetmsg
Getmsg error: function not implemented Linux 2.6.22-14-generic does not actually implement the getmsg file as demonstrated on Solaris.
========================================================== ============================
Section 14.4 is not understood yet. skip this step first.
What is stream?
========================================================== ==========================================
Csapp Chinese Version p743 check_clients function 21 Note: EOF detected., remove descriptor from pool
When Will EOF appear? Now that the client closes its connection, the server can detect the EOF.
========================================================== ==================================
Apue14.8 implements two functions: readn and writen to read and write data to FIFO, terminal, network, and stream devices.
These devices satisfy these two properties:
1> the data returned by a read operation may be less than the required data.
2> A write operation may return less than the specified number of bytes.
The two pieces of code on the 390 page seem good, but there are actually problems.
Csapp11.4.1 also implements two similar functions: rio_readn and rio_writen. The comparison of the two is in another article.
========================================================== ================
The statement 14-12 is incorrect!
14-12.c
Thinkhy @ thinkhy-LAPTOP :~ /Work/apue.2e/advio $ time./mcopy/wind/film/kongfuxiongmao. rmvb K. rm
Real 0m32. 683 S
User 0m0. 228 s
Sys 0m1. 160 s
Thinkhy @ thinkhy-LAPTOP :~ /Work/apue.2e/advio $ time./read </wind/film/kongfuxiongmao. rmvb> test. rm
Real 0m27. 864 s
User 0m0. 036 s
Sys 0m2. 276 s
Thinkhy @ thinkhy-LAPTOP :~ /Work/apue.2e/advio $ time./mcopy/wind/film/kongfuxiongmao. rmvb test. rm
Real 0m31. 267 s
User 0m0. 268 s
Sys 0m1. 000 s
========================================================== ============================
Struct timeval {
Long TV _sec;/* seconds */
Long TV _usec;/* microseconds */
}
========================================================== ==============================
P703 ex14.8 C-14.c v
Linux 2.6.22 65536
========================================================== ================================
Exercise 14.3 is a bit confused.
========================================================== ================================
O_rdonly is defined in the header file fcntl. h.
========================================================== ================================
A debugging error occurs:
Program received signal SIGSEGV, segmentation fault.
0x08000001b in main (argc = 1, argv = cannot access memory at address 0xb9a352e0
At ex14-9.c: 7
7 # include <sys/STAT. h>
========================================================== ==========================================================
14.4 Streams not understood
========================================================== ========================
Sheung Shui Mu asked how to make the Second grep parameter support regular expressions
Grep XX dir supports regular expressions