A summary of advanced programming v2cn in UNIX

Source: Internet
Author: User
Tags sleep function unix domain socket

A summary of advanced programming v2cn in UNIX
----
Date, January 1, March 24, 2013
Blog, http://blog.csdn.net/shunqiziranhao007/article/details/8712863
----
Netizens, master of Huashan, can take a look at reading notes if you are interested.

Http://www.cnblogs.com/biyeymyhjob/category/400821.html

----
March 24, 2013
----
Learning apue is very painful. You may encounter something you cannot understand from time to time. The previous examples are quite simple and easy to learn. The more I learn, the more I get tired of using ubuntu.
The source code is not very compatible with the Chinese version of the book, it is inconvenient to use, some code to find. The original source code is compatible with the English version.
Later, I saw a book "The Linux programming interface" for Linux APIs. I had a high rating on the Internet. I 'd better study it.

----
Chapter 1 Basic UNIX knowledge 1
----
1.1 Introduction 1
1.2 UNIX architecture 1
1.3 login 1
1.4 files and directories 3
1.5 Input and Output 6
1.6 programs and processes 8
1.7 error handling 10
1.8 user ID 12
1.9 signal 14
1.10 Time Value 15
1.11 system calls and database functions 16
1.12 Conclusion 17
Exercise 18

----
Chapter 19 UNIX standardization and Implementation 19
----
2.1 Introduction 19
2.2 UNIX standardization 19
2.3 UNIX system implementation 26
2.4 relationship between standards and implementations 28
2.5 limit 29
2.6 Option 42
2.7 function test macro 44
2.8 basic system data type 45
2.9 conflict between standards 45
2.10 summary 46
Exercise 46

----
Chapter 1 documents I/O 47
----
3.1 Introduction 47
3.2 file descriptor 47
3.3 OPEN function 48
3.4 creat function 49
3.5 close function 50
3.6 lseek function 50
3.7 READ function 53
3.8 write function 54
3.9 I/O efficiency 54
3.10 file sharing 56
3.11 atomic operation 59
3.12 DUP and dup2 functions 60
3.13 sync, fsync, and fdatasync functions 61
3.14 fcntl function 62
3.15 ioctl function 66
3.16/dev/FD 67
3.17 summary 68
Exercise 68
----
The file I/O is not buffered, and the standard I/O is buffered.

----
Chapter 1 files and directories 71
----
4.1 Introduction 71
4.2 stat, fstat, and lstat functions 71
4.3 file type 72
4.4 set user ID and set group ID 74
4.5 File Access Permissions 75
4.6 ownership of new files and directories 77
4.7 Access Function 77
4.8 umask function 79
4.9 CHMOD and fchmod functions 81
4.10 sticky position 83
4.11 chown, fchown, and lchown functions 84
4.12 file length 85
4.13 file truncation 86
4.14 file system 86
4.15 Functions 89: Link, unlink, remove, and rename
4.16 symbolic link 91
4.17 symlink and readlink functions 94
4.18 file time 94
4.19 utime function 95
4.20 mkdir and rmdir functions 97
4.21 read directory 98
4.22 chdir, fchdir, and getcwd functions 102
4.23 special device files 104
4.24 file access limit summary 106
4.25 Conclusion 106
Exercise 107

----
Chapter 4 standard I/O Library 5th
----
5.1 Introduction 109
5.2 stream and file object 109
5.3 Standard input, standard output, and standard error 110
5.4 buffer 110
5.5 open stream 112
5.6 read and write stream 114
5.7 each row I/O 116
5.8 standard I/O efficiency 117
5.9 binary I/O 119
5.10 locate stream 120
5.11 format I/O 121
5.12 Implementation Details 125
5.13 temporary files 127
5.14 standard I/O replacement software 130
5.15 conclusion 130
Exercise 130

----
Chapter 2 system data files and information 6th
----
6.1 Introduction 133
6.2 Password File 133
6.3 shadow password 136
6.4 sets of files 137
6.5 additional group id138
6.6 differences 139
6.7 other data files 139
6.8 Logon account record 140
6.9 System ID 141
6.10 time and date routine 142
6.11 conclusion 146
Exercise 146

----
Chapter 2 process environment 7th
----
7.1 Introduction 147
7.2 main function 147
7.3 Process Termination 147
7.4 command line parameters 151
7.5 environment table 152
7.6 C program storage space layout 152
7.7 shared library 154
7.8 memory allocation 154
7.9 environment variable 157
7.10 setjmp and longjmp functions 159
7.11 getrlimit and setrlimit functions 164
7.12 Conclusion 168
Exercise 168

----
Chapter 4 Process Control 8th
----
8.1 Introduction 171
8.2 process identifier 171
8.3 fork function 172
8.4 vfork function 176
8.5 exit function 178
-- _ Exit is different from exit.
8.6 wait and waitpid functions 179
8.7 waitid function 183
8.8 wait3 and wait4 functions 184
8.9 competitive conditions 185
8.10 exec function 188
8.11 change the user ID and group ID 192
8.12 interpreter file 196
8.13 system function 200
8.14 process accounting 203
8.15 user ID 208
8.16 process time 208
8.17 conclusion 210
Exercise 211

----
Chapter 2 process relationship 9th
----
9.1 Introduction 213
9.2 terminal login 213
9.3 network login 216
9.4 process group 218
9.5 session 219
9.6 control terminal 220
9.7 tcgetpgrp, tcsetpgrp, and tcgetsid functions 221
9.8 job control 222
9.9 shell execution program 225
9.10 orphan process group 228
9.11 FreeBSD implementation 230
9.12 conclusion 231
Exercise 232

----
Chapter 4 signal 10th
----
10.1 Introduction 233
10.2 signal concept 233
-- Man kill: Check the constant values of some signals.
10.3 signal function 240
10.4 unreliable signal 242
10.5 interrupted system calls 244
10.6 reentrant function 246
10.7 sigcld semantics 248
10.8 reliable signal terms and semantics 250
-- This part should be well understood.
10.9 kill and raise functions 251
10.10 alarm and pause functions 252
10.11 Signal Set 256
10.12 sigprocmask function 258
10.13 sigpending function 259
10.14 sigaction function 261
10.15 sigsetjmp and siglongjmp functions 266
10.16 sigsuspend function 268
-- Suspends the process and blocks the specified signal.
10.17 abort function 274
10.18 system function 276
10.19 sleep function 280
10.20 job control signal 282
10.21 other features 284
10.22 conclusion 285
Exercise 285

----
Chapter 4 thread 11th
----
11.1 Introduction 287
11.2 thread concept 287
The advantages of the thread.
11.3 thread ID 288
Pthread_t, pthread_equal, pthread_self.
11.4 thread creation 288
Pthread_create,
11.5 thread termination 291
That is, the thread exits, returns, is canceled, and takes the initiative to pthread_exit. pthread_join, pthread_cancel.
Pthread_cleanup_push, pthread_cleanup_pop. pthread_detach.
Process primitives and thread primitives.
11.6 thread synchronization 297
Mutex, pthread_mutex_init, pthread_mutex_destroy, pthread_mutex_lock, pthread_mutex_trylock, pthread_mutex_unlcok.
Read/write lock rwlock, pthread_rwlock_init, unlock, pthread_rwlock_rdlock, pthread_rwlock_wrlock, pthread_rwlock_unlock. pthread_rwlock_tryrdlock, pthread_rwlock_trywrlock.
Condition variables. pthread_cond_init, pthread_cond_destroy, pthread_cond_wait, pthread_cond_timewait. pthread_cond_signal, pthread_cond_broadcast.
11.7 Conclusion 311
Exercise 311

----
Chapter 4 thread control 12th
----
12.1 introduction 313
12.2 thread limit 313
12.3 thread attribute 314
Pthread_attr_init, pthread_attr_destroy, pthread_attr_getdetachstate, pthread_attr_setdetachstate, pthread_attr_getstack, pthread_attr_setstack,

12.4 synchronization property 318
Mutex attribute, read/write lock attribute, and condition variable attribute.
12.5 re-import 324
12.6 thread private data 328
12.7 cancel option 331
12.8 threads and signals 333
12.9 threads and fork 336
12.10 threads and I/O 339
12.11 Conclusion 340
Exercise 340
----
This chapter is hard to understand.

----
Chapter 4 daemon 13th
----
13.1 Introduction 341
13.2 daemon features 341
-- The PS-axj and ppid 0 processes are kernel processes. Process 1 is usually init.
-- Note that most of the Daemons run with superuser privilege (a user ID of 0 ). none of the daemons has a controlling terminal: the terminal name is set to a question mark, and the terminal foreground process group is 1. finally, note that the parent of most
Of these daemons is the INIT process.
13.3 programming rules 342
13.4 error records 345
Openlog, syslog, closelog, setlogmask.
13.5 Single Instance daemon 348
13.6 daemon practices 350
13.7 customer process-server process model 354
13.8 Conclusion 354
Exercise 354

----
Chapter 4 advanced I/o355
----
14.1 introduction 355
14.2 non-blocking I/O 355
14.3 record lock 357
-- The forced lock enables the kernel to check each open read write system call and check whether the calling process violates a lock for the files being accessed.
-- Enable the set group ID and disable the group execution bit for a specific file, and enable the mandatory lock mechanism for the file.
14.4 streams 370
-- Ubuntu does not support streams.
14.5 I/O multi-channel transfer 379
14.5.1 functions of select and pselect 381
14.5.2 poll function 384
14.6 asynchronous I/O 386
14.6.1 System V asynchronous I/O 386
14.6.2 BSD asynchronous I/O 387
14.7 readv and writev functions 387
14.8 readn and writen functions 389
14.9 storage ing I/O 390
14.10 conclusion 395
Exercise 396

----
Chapter 2 inter-process communication 15th
----
15.1 introduction 397
15.2 pipelines 398
15.3 popen and pclose functions 403
15.4 collaborative process 408
15.5 FIFO 412
15.6 xsi IPC 415
15.6.1 identifier and key 415
15.6.2 permission structure 416
15.6.3 structure limit: 417
15.6.4 advantages and disadvantages 417
15.7 Message Queue 418
15.8 semaphores 422
15.9 shared storage 427
15.10 customer process-server process attribute 432
15.11 conclusion 434
Exercise 434
----
You can see unp2.

----
Chapter 2 network IPC: Socket 16th
----
16.1 introduction 437
16.2 socket descriptor 437
16.3 addressing 439
16.4 establish a connection 450
16.5 data transmission 452
16.6 socket option 464
16.7 out-of-band data 466
16.8 non-blocking and asynchronous I/O 467
16.9 conclusion 468
Exercise 468
----
You can check the unp1.

----
Chapter 2 advanced inter-process communication 17th
----
17.1 introduction 469
17.2 streams-based pipelines 469
17.2.1 named streams pipeline 472
17.2.2 unique connection 473
17.3 Unix domain socket 476
17.3.1 Unix domain socket 477
17.3.2 unique connection 478
17.4 transfer file descriptor 482
17.4.1 transfer file descriptor 484 through a streams-Based Pipeline
17.4.2 transfer file descriptor 486 through Unix domain socket
17.5 Open Server Version 1 493
17.6 Open Server Version 2 498
17.7 conclusion 505
Exercise 505
----
You cannot see it.

----
Chapter 4 Terminal I/o507
----
18.1 Introduction 507
18.2 Summary 507
-- Canonicalized, line, non-canonicalized, and character.
18.3 special input character 512
18.4 obtain and set terminal properties 516
18.5 Terminal Option flag 516
18.6 stty command 522
18.7 baud rate function 523
18.8 row control functions 524
18.9 terminal ID 524
18.10 standard mode 529
18.11 non-standard mode 532
18.12 terminal window size 537
18.13 termcap, terminfo and curses 539
18.14 conclusion 540
Exercise 540

----
Chapter 2 Pseudo Terminal 19th
----
19.1 introduction 541
19.2 overview 541
19.3 open a Pseudo Terminal Device 544
19.3.1 streams-based Pseudo Terminal 547
19.3.2 BSD-based Pseudo Terminal 549
19.3.3 Linux-based Pseudo Terminal 551
19.4 pty_fork function 553
19.5 Pty program 555
19.6 use the Pty program 559
19.7 advanced features 564
19.8 conclusion 565
Exercise 565

----
Chapter 2 database function library 20th
----
20.1 introduction 567
20.2 history 567
20.3 function library 568
20.4 Implementation overview 569
20.5 centralized or non-centralized 572
20.6 concurrency 574
20.7 construct a function library 574
20.8 source code 575
20.9 performance 598
20.10 conclusion 600
Exercise 601
----
Study hard.

----
Chapter 2 communication with network printers 21st
----
21.1 introduction 603
21.2 Network Printing Protocol 603
21.3 Hypertext Transfer Protocol 605
21.4 print offline technology 605
21.5 source code 607
21.6 conclusion 644
Exercise 645
----
No.

Appendix A function prototype 647
Appendix B other source code 677
Appendix C Exercise answers 685
Bibliography 709
Index 715

Contact Us

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.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.