Advanced Programming In The UNIX Environment: Second Edition

3y ago
55 Views
8 Downloads
5.24 MB
1.4K Pages
Last View : 1d ago
Last Download : 2m ago
Upload by : Cannon Runnels
Transcription

Advanced Programming in the UNIX Environment: Second EditionBy W. Richard Stevens, Stephen A. Rago.Publisher: Addison Wesley ProfessionalPub Date: June 17, 2005ISBN: 0201433079Pages: 960Table of Contents Index"Stephen Rago's update is a long overdue benefit to the community of professionals using the versatile family of UNIX and UNIX-likeoperating environments. It removes obsolescence and includes newer developments. It also thoroughly updates the context of alltopics, examples, and applications to recent releases of popular implementations of UNIX and UNIX-like environments. And yet, itdoes all this while retaining the style and taste of the original classic."--Mukesh Kacker, cofounder and former CTO of ProntoNetworks, Inc."One of the essential classics of UNIX programming."--Eric S. Raymond, author of The Art of UNIX Programming"Thisis the definitive reference book for any serious or professional UNIX systems programmer. Rago has updated and extended theclassic Stevens text while keeping true to the original. The APIs are illuminated by clear examples of their use. He also mentions manyof the pitfalls to look out for when programming across different UNIX system implementations and points out how to avoid thesepitfalls using relevant standards such as POSIX 1003.1, 2004 edition and the Single UNIX Specification, Version 3."--Andrew Josey,Director, Certification, The Open Group, and Chair of the POSIX 1003.1 Working Group"Advanced Programming in the UNIX Environment, Second Edition, is an essential reference for anyone writing programs for a UNIX system. It's the first book I turn to whenI want to understand or re-learn any of the various system interfaces. Stephen Rago has successfully revised this book to incorporatenewer operating systems such as GNU/Linux and Apple's OS X while keeping true to the first edition in terms of both readability andusefulness. It will always have a place right next to my computer."--Dr. Benjamin Kuperman, Swarthmore CollegePraise for the FirstEdition"Advanced Programming in the UNIX Environment is a must-have for any serious C programmer who works under UNIX. Itsdepth, thoroughness, and clarity of explana-tion are unmatched."--UniForum Monthly"Numerous readers recommended AdvancedProgramming in the UNIX Environment by W. Richard Stevens (Addison-Wesley), and I'm glad they did; I hadn't even heard of thisbook, and it's been out since 1992. I just got my hands on a copy, and the first few chapters have been fascinating."--Open SystemsToday"A much more readable and detailed treatment of UNIX internals can be found in Advanced Programming in the UNIX Environment by W. Richard Stevens (Addison-Wesley). This book includes lots of realistic examples, and I find it quite helpful when Ihave systems programming tasks to do."--RS/Magazine"This is the definitive reference book for any serious or professional UNIXsystems programmer. Rago has updated and extended the original Stevens classic while keeping true to the original."--Andrew Josey,Director, Certification, The Open Group, and Chair of the POSIX 1003.1 Working GroupFor over a decade, serious C programmershave relied on one book for practical, in-depth knowledge of the programming interfaces that drive the UNIX and Linux kernels: W.Richard Stevens' Advanced Programming in the UNIX Environment. Now, Stevens' colleague Stephen Rago has thoroughly updatedthis classic to reflect the latest technical advances and add support for today's leading UNIX and Linux platforms.Rago carefullyretains the spirit and approach that made this book a classic. Building on Stevens' work, he begins with basic topics such as files,directories, and processes, carefully laying the groundwork for understanding more advanced techniques, such as signal handling andterminal I/O.Substantial new material includes chapters on threads and multithreaded programming, using the socket interface to driveinterprocess communication (IPC), and extensive coverage of the interfaces added to the latest version of the POSIX.1 standard.Nearly all examples have been tested on four of today's most widely used UNIX/Linux platforms: FreeBSD 5.2.1; the Linux 2.4.22kernel; Solaris 9; and Darwin 7.4.0, the FreeBSD/Mach hybrid underlying Apple's Mac OS X 10.3.As in the first edition, you'll learnthrough example, including more than 10,000 lines of downloadable, ANSI C source code. More than 400 system calls and functionsare demonstrated with concise, complete programs that clearly illustrate their usage, arguments, and return values. To tie togetherwhat you've learned, the book presents several chapter-length case studies, each fully updated for contemporaryenvironments.Advanced Programming in the UNIX Environment has helped a generation of programmers write code with exceptional

power, performance, and reliability. Now updated for today's UNIX/Linux systems, this second edition will be even more indispensable.

Advanced Programming in the UNIX Environment: Second EditionBy W. Richard Stevens, Stephen A. Rago.Publisher: Addison Wesley ProfessionalPub Date: June 17, 2005ISBN: 0201433079Pages: 960Table of Contents IndexCopyrightPraise for Advanced Programming in the UNIX Environment, Second EditionPraise for the First EditionAddison-Wesley Professional Computing SeriesForewordPrefaceIntroductionChanges from the First EditionAcknowledgmentsPreface to the First EditionIntroductionUnix StandardsOrganization of the BookExamples in the TextSystems Used to Test the ExamplesAcknowledgmentsChapter 1. UNIX System OverviewSection 1.1. IntroductionSection 1.2. UNIX ArchitectureSection 1.3. Logging InSection 1.4. Files and DirectoriesSection 1.5. Input and OutputSection 1.6. Programs and ProcessesSection 1.7. Error HandlingSection 1.8. User IdentificationSection 1.9. SignalsSection 1.10. Time ValuesSection 1.11. System Calls and Library FunctionsSection 1.12. SummaryExercisesChapter 2. UNIX Standardization and ImplementationsSection 2.1. IntroductionSection 2.2. UNIX Standardization

Section 2.3. UNIX System ImplementationsSection 2.4. Relationship of Standards and ImplementationsSection 2.5. LimitsSection 2.6. OptionsSection 2.7. Feature Test MacrosSection 2.8. Primitive System Data TypesSection 2.9. Conflicts Between StandardsSection 2.10. SummaryExercisesChapter 3. File I/OSection 3.1. IntroductionSection 3.2. File DescriptorsSection 3.3. open FunctionSection 3.4. creat FunctionSection 3.5. close FunctionSection 3.6. lseek FunctionSection 3.7. read FunctionSection 3.8. write FunctionSection 3.9. I/O EfficiencySection 3.10. File SharingSection 3.11. Atomic OperationsSection 3.12. dup and dup2 FunctionsSection 3.13. sync, fsync, and fdatasync FunctionsSection 3.14. fcntl FunctionSection 3.15. ioctl FunctionSection 3.16. /dev/fdSection 3.17. SummaryExercisesChapter 4. Files and DirectoriesSection 4.1. IntroductionSection 4.2. stat, fstat, and lstat FunctionsSection 4.3. File TypesSection 4.4. Set-User-ID and Set-Group-IDSection 4.5. File Access PermissionsSection 4.6. Ownership of New Files and DirectoriesSection 4.7. access FunctionSection 4.8. umask FunctionSection 4.9. chmod and fchmod FunctionsSection 4.10. Sticky BitSection 4.11. chown, fchown, and lchown FunctionsSection 4.12. File SizeSection 4.13. File TruncationSection 4.14. File SystemsSection 4.15. link, unlink, remove, and rename FunctionsSection 4.16. Symbolic LinksSection 4.17. symlink and readlink Functions

Section 4.18. File TimesSection 4.19. utime FunctionSection 4.20. mkdir and rmdir FunctionsSection 4.21. Reading DirectoriesSection 4.22. chdir, fchdir, and getcwd FunctionsSection 4.23. Device Special FilesSection 4.24. Summary of File Access Permission BitsSection 4.25. SummaryExercisesChapter 5. Standard I/O LibrarySection 5.1. IntroductionSection 5.2. Streams and FILE ObjectsSection 5.3. Standard Input, Standard Output, and Standard ErrorSection 5.4. BufferingSection 5.5. Opening a StreamSection 5.6. Reading and Writing a StreamSection 5.7. Line-at-a-Time I/OSection 5.8. Standard I/O EfficiencySection 5.9. Binary I/OSection 5.10. Positioning a StreamSection 5.11. Formatted I/OSection 5.12. Implementation DetailsSection 5.13. Temporary FilesSection 5.14. Alternatives to Standard I/OSection 5.15. SummaryExercisesChapter 6. System Data Files and InformationSection 6.1. IntroductionSection 6.2. Password FileSection 6.3. Shadow PasswordsSection 6.4. Group FileSection 6.5. Supplementary Group IDsSection 6.6. Implementation DifferencesSection 6.7. Other Data FilesSection 6.8. Login AccountingSection 6.9. System IdentificationSection 6.10. Time and Date RoutinesSection 6.11. SummaryExercisesChapter 7. Process EnvironmentSection 7.1. IntroductionSection 7.2. main FunctionSection 7.3. Process TerminationSection 7.4. Command-Line ArgumentsSection 7.5. Environment ListSection 7.6. Memory Layout of a C Program

Section 7.7. Shared LibrariesSection 7.8. Memory AllocationSection 7.9. Environment VariablesSection 7.10. setjmp and longjmp FunctionsSection 7.11. getrlimit and setrlimit FunctionsSection 7.12. SummaryExercisesChapter 8. Process ControlSection 8.1. IntroductionSection 8.2. Process IdentifiersSection 8.3. fork FunctionSection 8.4. vfork FunctionSection 8.5. exit FunctionsSection 8.6. wait and waitpid FunctionsSection 8.7. waitid FunctionSection 8.8. wait3 and wait4 FunctionsSection 8.9. Race ConditionsSection 8.10. exec FunctionsSection 8.11. Changing User IDs and Group IDsSection 8.12. Interpreter FilesSection 8.13. system FunctionSection 8.14. Process AccountingSection 8.15. User IdentificationSection 8.16. Process TimesSection 8.17. SummaryExercisesChapter 9. Process RelationshipsSection 9.1. IntroductionSection 9.2. Terminal LoginsSection 9.3. Network LoginsSection 9.4. Process GroupsSection 9.5. SessionsSection 9.6. Controlling TerminalSection 9.7. tcgetpgrp, tcsetpgrp, and tcgetsid FunctionsSection 9.8. Job ControlSection 9.9. Shell Execution of ProgramsSection 9.10. Orphaned Process GroupsSection 9.11. FreeBSD ImplementationSection 9.12. SummaryExercisesChapter 10. SignalsSection 10.1. IntroductionSection 10.2. Signal ConceptsSection 10.3. signal FunctionSection 10.4. Unreliable SignalsSection 10.5. Interrupted System Calls

Section 10.6. Reentrant FunctionsSection 10.7. SIGCLD SemanticsSection 10.8. Reliable-Signal Terminology and SemanticsSection 10.9. kill and raise FunctionsSection 10.10. alarm and pause FunctionsSection 10.11. Signal SetsSection 10.12. sigprocmask FunctionSection 10.13. sigpending FunctionSection 10.14. sigaction FunctionSection 10.15. sigsetjmp and siglongjmp FunctionsSection 10.16. sigsuspend FunctionSection 10.17. abort FunctionSection 10.18. system FunctionSection 10.19. sleep FunctionSection 10.20. Job-Control SignalsSection 10.21. Additional FeaturesSection 10.22. SummaryExercisesChapter 11. ThreadsSection 11.1. IntroductionSection 11.2. Thread ConceptsSection 11.3. Thread IdentificationSection 11.4. Thread CreationSection 11.5. Thread TerminationSection 11.6. Thread SynchronizationSection 11.7. SummaryExercisesChapter 12. Thread ControlSection 12.1. IntroductionSection 12.2. Thread LimitsSection 12.3. Thread AttributesSection 12.4. Synchronization AttributesSection 12.5. ReentrancySection 12.6. Thread-Specific DataSection 12.7. Cancel OptionsSection 12.8. Threads and SignalsSection 12.9. Threads and forkSection 12.10. Threads and I/OSection 12.11. SummaryExercisesChapter 13. Daemon ProcessesSection 13.1. IntroductionSection 13.2. Daemon CharacteristicsSection 13.3. Coding RulesSection 13.4. Error LoggingSection 13.5. Single-Instance Daemons

Section 13.6. Daemon ConventionsSection 13.7. ClientServer ModelSection 13.8. SummaryExercisesChapter 14. Advanced I/OSection 14.1. IntroductionSection 14.2. Nonblocking I/OSection 14.3. Record LockingSection 14.4. STREAMSSection 14.5. I/O MultiplexingSection 14.6. Asynchronous I/OSection 14.7. readv and writev FunctionsSection 14.8. readn and writen FunctionsSection 14.9. Memory-Mapped I/OSection 14.10. SummaryExercisesChapter 15. Interprocess CommunicationSection 15.1. IntroductionSection 15.2. PipesSection 15.3. popen and pclose FunctionsSection 15.4. CoprocessesSection 15.5. FIFOsSection 15.6. XSI IPCSection 15.7. Message QueuesSection 15.8. SemaphoresSection 15.9. Shared MemorySection 15.10. ClientServer PropertiesSection 15.11. SummaryExercisesChapter 16. Network IPC: SocketsSection 16.1. IntroductionSection 16.2. Socket DescriptorsSection 16.3. AddressingSection 16.4. Connection EstablishmentSection 16.5. Data TransferSection 16.6. Socket OptionsSection 16.7. Out-of-Band DataSection 16.8. Nonblocking and Asynchronous I/OSection 16.9. SummaryExercisesChapter 17. Advanced IPCSection 17.1. IntroductionSection 17.2. STREAMS-Based PipesSection 17.3. UNIX Domain SocketsSection 17.4. Passing File DescriptorsSection 17.5. An Open Server, Version 1

Section 17.6. An Open Server, Version 2Section 17.7. SummaryExercisesChapter 18. Terminal I/OSection 18.1. IntroductionSection 18.2. OverviewSection 18.3. Special Input CharactersSection 18.4. Getting and Setting Terminal AttributesSection 18.5. Terminal Option FlagsSection 18.6. stty CommandSection 18.7. Baud Rate FunctionsSection 18.8. Line Control FunctionsSection 18.9. Terminal IdentificationSection 18.10. Canonical ModeSection 18.11. Noncanonical ModeSection 18.12. Terminal Window SizeSection 18.13. termcap, terminfo, and cursesSection 18.14. SummaryExercisesChapter 19. Pseudo TerminalsSection 19.1. IntroductionSection 19.2. OverviewSection 19.3. Opening Pseudo-Terminal DevicesSection 19.4. pty fork FunctionSection 19.5. pty ProgramSection 19.6. Using the pty ProgramSection 19.7. Advanced FeaturesSection 19.8. SummaryExercisesChapter 20. A Database LibrarySection 20.1. IntroductionSection 20.2. HistorySection 20.3. The LibrarySection 20.4. Implementation OverviewSection 20.5. Centralized or Decentralized?Section 20.6. ConcurrencySection 20.7. Building the LibrarySection 20.8. Source CodeSection 20.9. PerformanceSection 20.10. SummaryExercisesChapter 21. Communicating with a Network PrinterSection 21.1. IntroductionSection 21.2. The Internet Printing ProtocolSection 21.3. The Hypertext Transfer ProtocolSection 21.4. Printer Spooling

Section 21.5. Source CodeSection 21.6. SummaryExercisesAppendix A. Function PrototypesAppendix B. Miscellaneous Source CodeSection B.1. Our Header FileB.2 Standard Error RoutinesAppendix C. Solutions to Selected ExercisesChapter 1Chapter 2Chapter 3Chapter 4Chapter 5Chapter 6Chapter 7Chapter 8Chapter 9Chapter 10Chapter 11Chapter 12Chapter 13Chapter 14Chapter 15Chapter 16Chapter 17Chapter 18Chapter 19Chapter 20Chapter 21BibliographyIndex

CopyrightMany of the designations used by manufacturers and sellers to distinguish their products are claimedas trademarks. Where those designations appear in this book, and the publisher was aware of atrademark claim, the designations have been printed with initial capital letters or in all capitals.The authors and publisher have taken care in the preparation of this book, but make no expressed orimplied warranty of any kind and assume no responsibility for errors or omissions. No liability isassumed for incidental or consequential damages in connection with or arising out of the use of theinformation or programs contained herein.The publisher offers excellent discounts on this book when ordered in quantity for bulk purchases orspecial sales, which may include electronic versions and/or custom covers and content particular toyour business, training goals, marketing focus, and branding interests. For more information, pleasecontact:U.S. Corporate and Government Sales(800) 382-3419corpsales@pearsontechgroup.comFor sales outside the U.S., please contact:International Salesinternational@pearsoned.comVisit us on the Web: www.awprofessional.comLibrary of Congress Cataloging-in-Publication Data:Stevens, W. Richard.Advanced programming in the Unix environment / W. Richard Stevens,Stephen A. Rago.2nd ed.p. cm.Includes bibliographical references and index.ISBN 0-201-43307-9 (hardcover : alk. paper)1. Operating systems (Computers) 2. UNIX (Computer file) I. Rago,Stephen A. II. Title.QA76.76.O63S754 2005005.4'32dc222005007943Copyright 2005 Pearson Education, Inc.All rights reserved. Printed in the United States of America. This publication is protected by copyright,

and permission must be obtained from the publisher prior to any prohibited reproduction, storage in aretrieval system, or transmission in any form or by any means, electronic, mechanical, photocopying,recording, or likewise. For information regarding permissions, write to:Pearson Education, Inc.Rights and Contracts DepartmentOne Lake StreetUpper Saddle River, NJ 074580-201-43307-9Text printed in the United States on recycled paper at Courier in Westford, Massachusetts. Firstprinting, June 2005DedicationTo Jeanne

Praise for Advanced Programming in theUNIX Environment, Second Edition"Stephen Rago's update is a long overdue benefit to the community of professionals using theversatile family of UNIX and UNIX-like operating environments. It removes obsolescence andincludes newer developments. It also thoroughly updates the context of all topics, examples,and applications to recent releases of popular implementations of UNIX and UNIX-likeenvironments. And yet, it does all this while retaining the style and taste of the original classic."Mukesh Kacker, cofounder and former CTO of Pronto Networks, Inc."One of the essential classics of UNIX programming."Eric S. Raymond, author of The Art of UNIX Programming"This is the definitive reference book for any serious or professional UNIX systems programmer.Rago has updated and extended the classic Stevens text while keeping true to the original. TheAPIs are illuminated by clear examples of their use. He also mentions many of the pitfalls tolook out for when programming across different UNIX system implementations and points outhow to avoid these pitfalls using relevant standards such as POSIX 1003.1, 2004 edition and theSingle UNIX Specification, Version 3."Andrew Josey, Director, Certification, The Open Group, and Chair of the POSIX 1003.1 WorkingGroup"Advanced Programming in the UNIX Environment, Second Edition, is an essential referencefor anyone writing programs for a UNIX system. It's the first book I turn to when I want tounderstand or re-learn any of the various system interfaces. Stephen Rago has successfullyrevised this book to incorporate newer operating systems such as GNU/Linux and Apple's OS Xwhile keeping true to the first edition in terms of both readability and usefulness. It will alwayshave a place right next to my computer."Dr. Benjamin Kuperman, Swarthmore College

Praise for the First Edition"Advanced Programming in the UNIX Environment is a must-have for any serious Cprogrammer who works under UNIX. Its depth, thoroughness, and clarity of explanation areunmatched."UniForum Monthly"Numerous readers recommended Advanced Programming in the UNIX Environment by W.Richard Stevens (Addison-Wesley), and I'm glad they did; I hadn't even heard of this book, andit's been out since 1992. I just got my hands on a copy, and the first few chapters have beenfascinating."Open Systems Today"A much more readable and detailed treatment of [UNIX internals] can be found in AdvancedProgramming in the UNIX Environment by W. Richard Stevens (Addison-Wesley). This bookincludes lots of realistic examples, and I find it quite helpful when I have systems programmingtasks to do."RS/Magazine

Addison-Wesley Professional ComputingSeriesBrian W. Kernighan, Consulting EditorMatthew H. Austern, Generic Programming and the STL: Using and Extending the C Standard Template LibraryDavid R. Butenhof, Programming with POSIX ThreadsBrent Callaghan, NFS IllustratedTom Cargill, C Programming StyleWilliam R. Cheswick/Steve

Nearly all examples have been tested on four of today's most widely used UNIX/Linux platforms: FreeBSD 5.2.1; the Linux 2.4.22 kernel; Solaris 9; and Darwin 7.4.0, the FreeBSD/Mach hybrid underlying Apple's Mac OS X 10.3.As in the first edition, you'll learn through example, including more than 10,000 lines of downloadable, ANSI C source code.

Related Documents:

May 02, 2018 · D. Program Evaluation ͟The organization has provided a description of the framework for how each program will be evaluated. The framework should include all the elements below: ͟The evaluation methods are cost-effective for the organization ͟Quantitative and qualitative data is being collected (at Basics tier, data collection must have begun)

Silat is a combative art of self-defense and survival rooted from Matay archipelago. It was traced at thé early of Langkasuka Kingdom (2nd century CE) till thé reign of Melaka (Malaysia) Sultanate era (13th century). Silat has now evolved to become part of social culture and tradition with thé appearance of a fine physical and spiritual .

On an exceptional basis, Member States may request UNESCO to provide thé candidates with access to thé platform so they can complète thé form by themselves. Thèse requests must be addressed to esd rize unesco. or by 15 A ril 2021 UNESCO will provide thé nomineewith accessto thé platform via their émail address.

̶The leading indicator of employee engagement is based on the quality of the relationship between employee and supervisor Empower your managers! ̶Help them understand the impact on the organization ̶Share important changes, plan options, tasks, and deadlines ̶Provide key messages and talking points ̶Prepare them to answer employee questions

Dr. Sunita Bharatwal** Dr. Pawan Garga*** Abstract Customer satisfaction is derived from thè functionalities and values, a product or Service can provide. The current study aims to segregate thè dimensions of ordine Service quality and gather insights on its impact on web shopping. The trends of purchases have

Unix 101: Introduction to UNIX (i.e. Unix for Windows Users) Mark Kegel September 7, 2005 1 Introduction to UNIX (i.e. Unix for Windows Users) The cold hard truth · this course is NOT sponsored by the CS dept. · you will not receive any credit at all introduce ourselv

UNIX and POSIX APIs: The POSIX APIs, The UNIX and POSIX Development Environment, API Common Characteristics. UNIT – 2 6 Hours UNIX Files: File Types, The UNIX and POSIX File System, The UNIX and POSIX File Attributes, Inodes in UNIX

Chính Văn.- Còn đức Thế tôn thì tuệ giác cực kỳ trong sạch 8: hiện hành bất nhị 9, đạt đến vô tướng 10, đứng vào chỗ đứng của các đức Thế tôn 11, thể hiện tính bình đẳng của các Ngài, đến chỗ không còn chướng ngại 12, giáo pháp không thể khuynh đảo, tâm thức không bị cản trở, cái được