Apue. h is a file written by the author. It contains common header files and is not provided by the system. This includes common header files and definitions of error handling functions. It is really convenient to use.
The content of apue. h is as follows:
#ifndef _APUE_H #define _APUE_H #define _XOPEN_SOURCE 600 /* Single UNIX Specification, Version 3 */ #include
To use it, perform the following operations to complete the configuration.
UNIX advanced environment programming (7) standard I/O function library and I/O function library
1 Binary IO (Binary IO)
In the previous article, we learned about character-by-character read/write and row-by-row read/write functions.
If we want to read and write binary files and want to read and write the entire file, although these two functions can be implemented, they will obviously be troublesome and th
Unix shell programming (1)
Unix only recognizes three basic file types: common files, directory files, and special files.Normal file: any file on the system that contains data, test, program instructions, or just about anything else.
Number of words in the Statistical File: WC commandFor example:[Root @ localhost test] # WC makefile22 84 600 makefileThe first dig
"ABCD" at the beginning of the file, then move the file offset to 10 bytes from the start, and write "ABCD" at the beginning, then in the file. hole forms a hole between 4th bytes and 9th bytes.
#include
Compile the program, generate the writedemo file, and then execute the writedemo file,
Lien000034: Demo $ gcc-O writedemo write_demo.clien000034: Demo $. /writedemolien000034: Demo $ LS-l file. hole-RW-r ----- 1 lien000034 lien000034 14 August 20 21:37 file. holelien000034: Demo $ OD-C file. h
improve the efficiency of learning and use.
The book according to the level of QT knowledge structure and the reader's Learning Law step-by-step, to explain. For each knowledge point in the book to explain, all strive to make readers not only "know", and "know Why". Only in this way can we really let the reader grasp the essence of knowledge and thus improve the ability of engineering practice. Finally, f
1. Compile. for C + +, usually file independent compilation--generates a standalone intermediate target file. This is mainly a semantic grammar check, the correctness of the Declaration of functions and variables. This requires the introduction of the appropriate header file for the compiler to see the definition. The compiled generated files are. obj files under Windows, and. o Files under UNIX.
2. Connection. when connecting, it is mainly connected
loopos@webols:~/work/apue$ gcc -o fig11.2 fig11.2.c/tmp/ccXTzASv.o: In function `main':fig11.2.c:(.text+0x2fe): undefined reference to `pthread_create'collect2: ld returned 1 exit status
This error is similar to the prompt that many mathematical functions cannot find when using the The cause of this problem is:The pthread library is not the default library in Linux. You must use the static library libpthread for connection. a, so when using pthread_create () to create a thread and other function
consistent with the function prototypePerror shown earlier in the book.
The following errors were fixed in the third printing.
Page 194, function prototypesSetenv and unsetenv. These functions return-1 on error, which is more specific than simply a nonzero return value.
Page 306, Figure 10.4. The Corrigenda for the Single UNIX Specification addedAbort and sockatmark to the list of reentrant functions.
hang-out operation simply adds a semaphore value of 1 (increasing the number of available resources) and wakes up waiting for the semaphore value to become any thread greater than 0. 4.2 System v Signal VolumeThe System v Semaphore adds another level of complexity.* * Count Semaphore set: one or more semaphores (constituting a set), each of which is a count semaphore. **system v semaphores generally refer to the set of counting semaphores. POSIX semaphores, in general, refer to a single count s
Client and server program templates supported by network programming:
1. connect multiple clients to the server at the same time, that is, the service program can serve multiple clients at the same time;
2. The server supports socket pair reuse, that is, even in the time_wait status, the server can be restarted;
3. The server can check whether the client is disconnected;
4. The standard input of the client is displayed, and the server displays the con
"Linux/unix System Programming Manual" Reading notes catalogueIn Linux, everything is file. Therefore, the file system occupies an important position in the Linux system. This article is mainly about the properties of the file, just a little mention of the file system, in the future if more in-depth research will be written.The relationship between disk partitioning and the file systemFiles (directories) in
Unix programming FAQ v0.10
I accidentally found a Unix programming FAQ. Fortunately, it has been translated into a Chinese version! Although old, it is still useful.Provided by linuxforum.net. Thank you for your contribution.
The following is the chapter directory. The original Article is still on linuxforum.net, so it
buffer with that row. The second printf before exit appends its data to an existing buffer. When the process terminates, the contents of its buffer are written to the appropriate file. One thing to note about the above procedure is that when redirecting the standard output of the parent process, the standard output of the child process is also redirected. One feature of fork is that all open file descriptions of the parent process are nonalphanumeric copied into the child process. The parent an
Most of the UNIX errors return a negative integer or error code, and 0 is the error code.1. A file descriptor will be returned when each file is opened2.unix standard input and output error code file descriptors are replaced with constant Stdin_fileno,stdout_fileno,strerr_fileno (in unistd.h file) in 0 1 2,posix.1 respectively3.Open function Use (do not remember, write more, more practice, just remember, do
endspent (void );
3. group files
UNIX files contain the fields shown in. These fields are also included in the group structure defined in
POSIX defines the following two functions to find information about the user group based on the user name or user ID.
# Include
Struct Group * getgrgid (gid_t GID );
Struct Group * getgrnam (const char * Name );
Similar to accessing a password file. To access the entire group file, you need to use the following
the synchronization of threads is very important. threads can be divided into user-level threads and core-level threads. (1) The user-level thread is mainly to solve the problem of switching between the top and bottom, its scheduling algorithm and scheduling process is the user's own choice of decision, at run time does not need a specific kernel support, the operating system will provide a library function, including the creation of threads, scheduling, revocation and other functions. And the
NULL, we start to run the program .... (The difference with UNP is that the relationship between our threads and tasks is set up before, but it's not a good thing, just putting the UNP of the thread to the task in the Thread_manger function.)Essentially, you get the task randomly.Pthread_create (thread_manager_tid, NULL, Thread_manager, NULL);The runtime of this thread is the part that is not in UNP. The main purpose is to get the idle thread structure from the idle thread structure, and to est
manipulation functions:#include void *memset (void *dest, int c, size_t len);void *memcpy (void *dest, const void *SRC, size_t nbytes);int memcmp (const void *PTR1, const void *PTR2, size_t nbytes);the ASCII string---the binary value of the > Network byte order (the value stored in the socket address structure) to convert the internetwork address.#include int Inet_aton (const char *strptr, struct in_addr *addrptr);/** returns: 1 if the string is valid, otherwise 0**/in_addr_t inet_addr (const c
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.