Problems with the library of APUE under Linux:
It is from
The source code package for the For Linux platform given by www.kohala.com, is estimated to be a bit old:
The libc of GCC3.3.3 seems to have changed a lot, when compiled APUE libraysc.a and myls.c link, the GCC warned Sys_ERRN did not encourage (deprecated), and the best STRERROR, in fact, sys_errn is in Apue Inside the library, I use this file throughout the entire file, which means that I use the strers provided with the strerror alternative to the function provided by the APUE (you can also remove the strerror.c file from Makefile), re- Compile the APUE library, the warning message will no longer appear when compiling MYLS.
Program 1.2, print the input to the output, read is to read the wrap as return condition, interesting is when I
Enter a string of characters and end with Ctrl-D, the READ is also returned, and the output and input are displayed in the same line. My conclusion is:
This is another condition returned by READ, because there is no line, input and output are displayed in one line. This Ctrl-D must be ignored, otherwise the program should exit. Read returns 0 when ctrl-d is input separately.
The issue is:
When is READ back?
Program 1.3, with a buffered C function 1.2 function, the operation principle is worth considering: the code is looped to call Getc, then loop the PUTC output to the standard output, but every time it is running. All again, it seems to be different from the procedure, my understanding is: When the program first calls Getc, once the buffer is found to be empty, the internal start of the READ is called, and the READ will not return. Returns a string of internal buffers that enter the stdio, and the getC returns the first character, and the getC is directly returned from the internal buffer to the remaining characters. When the Getc takes the character in the optical buffer, it enters the pair The loop call of READ. . . After returning from the carriage return again, fill in the buffer again, taking the character again until the EOF is good: reduce the switching between the system call and the user and the core state. The program 1.8 installed a callback function of the signal, but simply print a row of information with Printf, but when compiled, it always lags the display, there is no way, there is only to force refresh output in the callback function, and FFLUSH is normal. I firmly believe that Linux's STDIO C function library is read, and it is not seen that the carriage return will not look back. (Because I didn't make a modification, I always knocked the bus. The information to be displayed in the callback function was displayed on the screen) The exercise 3 actually asked such a question: The constant non-pointer value in the function parameter makes sense? Oh, no. But I didn't answer. . . In addition, I didn't expect the answer to the answer.