Cart
Free US shipping over $10
Proud to be B-Corp

POSIX Programmer's Guide Donald Lewine

POSIX Programmer's Guide By Donald Lewine

POSIX Programmer's Guide by Donald Lewine


$4.14
Condition - Good
Only 1 left

Summary

This guide is intended as an explanation of the POSIX standard and as a reference for the POSIX.1 programming library, and should help the user write more portable programs.

Faster Shipping

Get this product faster from our US warehouse

POSIX Programmer's Guide Summary

POSIX Programmer's Guide by Donald Lewine

Most UNIX systems today are POSIX-compliant because the Federal government requires it for its purchases. Given the manufacturer's documentation, however, it can be difficult to distinguish system-specific features from those features defined by POSIX. This guide is intended as an explanation of the POSIX standard and as a reference for the POSIX.1 programming library, and should help the user write more portable programs.

About Donald Lewine

Donald Lewine has been writing computer programs for fun and profit since 1960. He has been teaching computer science in the State-of-the-Art (evening) program at Northeastern University for the past eight years. He has taught courses on Assembler, VAX/VMS, PASCAL, C and UNIX. This book was written and tested over the last two years at Northeastern University. Mr. Lewine spent 13 years with the Digital Equipment Corporation developing operating systems and central processing units. He was Technical Director for the MicroVAS Program when he left. For the past seven years, Mr. Lewine has been with Data General Corporation, currently as Director of Engineering. In this role he has been developing the AViiON family of open systems. He is a founder and a member of the Board of Directors of 88open, a member of the Board of Directors of UNIX International, and Data General's representative to the Open Software Foundation.

Table of Contents

POSIX Programmer's Guide Preface The POSIX Standard Documents Guide to POSIX for Programmers Programming Guide Reference Guide and Appendixes Assumptions Conventions CHAPTER 1 Introduction to POSIX and Portability Who is Backing POSIX? The POSIX Family of Standards The POSIX.1 Standard Document The Design of POSIX POSIX and UNIX POSIX and Non-UNIX Operating Systems POSIX, C, ANSI C, and Standard C Why Standard C? Working Outside the Standards Finding The POSIX Libraries Converting Existing Programs CHAPTER 2 Developing POSIX Applications The POSIX Development Environment The Standard C Compiler POSIX and C Libraries Converting Existing Programs A Porting Example An Alternate Approach Standard Header Files Template for a POSIX Application /* Feature test switches */ /* System headers */ /* Local headers */ /* Macros */ /* File scope variables */ /* External variables */ /* External functions */ /* Structures and unions */ /* Signal catching functions */ /* Functions */ /* Main */ Sample Program Portability Lab CHAPTER 3 Standard File and Terminal I/O Libraries and System Calls Standard Files Formatted Output Examples Pitfalls The vfprintf(), vprintf(), and vsprintf() Functions Character Output Functions The fputs() and puts() Functions The fputc(), putc(), and putchar() Functions Reading Lines of Input Pitfalls Additional Pitfall Other Character Input Functions The fgetc(), getc() and getchar() Functions The fgets() Function The gets() Function The ungetc() Function Opening and Closing Files Direct Input/Output functions The fwrite() and fread() Functions File Positioning Functions The fgetpos() and fsetpos() Functions The ftell() and fseek() Function The rewind() Function Managing Buffers Sample Program Portability Lab CHAPTER 4 Files and Directories Portable Filenames Directory Tree Current Working Directory Making and Removing Directories The rmdir() Function Simulating the mkdir() and rmdir() Functions Directory Structure Manipulating Directories Linking to a File Removing a File Renaming a File File Characteristics Retrieving a FileUs Characteristics Changing File Accessibility Changing the Owner of a File Setting File Access and Modification Times Reading Directories The opendir() Function The readdir() Function The closedir() Function The rewinddir() Function General Comments Complete Example Pitfall: Symbolic Links Portability Lab CHAPTER 5 Advanced File Operations Primitive File Operations File Descriptors Opening a file Reading from a File Writing to a File Fast File Copy Example Control Operations on a File F_GETFD/F_SETFD F_GETFL/F_SETFL F_SETLK/F_SETLKW/F_GETLK F_DUPFD Setting the File Position The dup() and dup2() Functions Closing a File FIFOs and Pipes File Creation Mask The umask() Function Mixing the Levels The fdopen() Function The fileno() Function Pitfalls Portability Lab CHAPTER 6 Working with Processes Process Creation The fork() Function The exec() Family of Function Example: Piping Output Through more Portability Note Process Termination The wait() and waitpid() Functions Terminating the Current Process Returning from main() Calling exit() Calling _exit() Calling abort() Terminating Another Process Signals Signal Actions Signal-Catching Functions Examine and Change Signal Action Standard C Signals POSIX Signals Example: Timing a System Function Signal Sets The sigemptyset() Function The sigfillset() Function The sigaddset() Function The sigdelset() Function Using the sigset Functions The sigismember() Function The sigprocmask() Function The sigpending() Function Wait for a Signal Sending a Signal Portability Lab CHAPTER 7 Obtaining Information at RunPtime Process Identification User Identification User IDs Group IDs System Identification Date and Time The time() Function The localtime() and gmtime() Functions The mktime() Function The strftime() Function The asctime() and ctime() Functions The difftime() Function The clock() and times() Functions Environment Variables The getenv() Function The sysconf() Function The pathconf() and fpathconf() Functions Portability Lab CHAPTER 8 Terminal I/O Terminal Concepts Setting Terminal Parameters The tcsetattr() and tcgetattr() Functions The termios Structure System V termio and POSIX termios Structures Example: Reading a Password Input Processing Output Processing Modem Control Non-Canonical I/O Input Modes Output Modes Control Modes Local Modes Control Characters Speed Storing Functions Line Control Functions The tcsendbreak() Function The tcdrain() Function The tcflush() Function The tcflow() Function Avoiding Pitfalls Example: Computer-to-Computer Communications Process Groups and Job Control Process Groups Foreground Process Background Process Session Controlling Terminal Get/Set Process Group The setsid() Function The setpgid() Function The tcsetpgrp() Function Portability Lab CHAPTER 9 POSIX and Standard C Common Usage C Standard C Getting Standard C The Standard C Preprocessor Translation Phases Macro Replacement Conversion of Macro Arguments to Strings Token Pasting New Directives Namespace Issues Names Reserved by the C Language Names Reserved by Header Files C Library Functions POSIX Library Functions Avoiding Pitfalls Function Prototypes Avoiding Pitfalls Writing New Programs Maintaining Old Programs Mixing Old and New Using const and volatile String Constants Data Type Conversions Character Sets Using Floating-point Data Using Data Structures Alignment Data Segment Layout Big-endian vs. Little-endian Internationalization Portability Lab CHAPTER 10 Porting to Far-off Lands Some Definitions Internationalization Localization Locale Locale Control Character and Codeset Messages Representation of Numbers Currency Dates Setting the Current Locale Character-handling Functions The isalpha(), islower(), and isupper() Functions The toupper() and tolower() Functions The isspace() Function The strcoll() Function The strxfrm() Function The strerror() and perror() Functions The strftime() Function Native Language Messages Message Catalogs The catopen() Function The catgets() Function The catclose() Function Local Numeric Formatting Asian Languages Multi-byte Characters Wide Characters Working with Multi-byte and Wide Characters The mbtowc() Function The mbstowcs() Function The wctomb() Function The wcstombs() Function The mblen() Function Portability Lab Library Functions abort() -- Causes abnormal process termination abs() -- Computes the absolute value of an integer access() -- Tests for file accessibility acos() -- Computes the principal value of arc cosine alarm() -- Schedules an alarm asctime() -- Converts a time structure to a string asin() -- Computes the principal value of the arc sine assert() -- Aborts the program if assertion is false atan() -- Computes the principal value of the arc tangent atan2() -- Computes the principal value of the arc tangent of y/x atexit() Registers a function to be called at normal program termination atof() -- Converts a text string to double atoi() -- Converts a text string to integer atol() -- Converts a text string to long integer bsearch() -- Searches a sorted array calloc() -- Allocates and zeroes memory ceil() -- Computes the smallest integer greater than or equal to x cfgetispeed() -- Reads terminal input baud rate cfgetospeed() -- Reads terminal output baud rate cfsetispeed() -- Sets terminal input baud rate cfsetospeed() -- Sets terminal output baud rate chdir() -- Changes the current working directory chmod() -- Changes file mode chown() -- Changes the owner and/or group of a file clearerr() -- Clears end-of-file and error indicators for a stream clock() -- Determines processor time used close() -- Closes a file closedir() -- Ends directory read operation cos() -- Computes the cosine function cosh() -- Computes the hyperbolic cosine function creat() -- Creates a new file or rewrites an existing one ctermid() -- Generates terminal pathname ctime() -- Formats a calendar time cuserid() -- Gets user name difftime() -- Computes the difference between two times div() -- Computes the quotient and remainder of an integer division dup() -- Duplicates an open file descriptor dup2() -- Duplicates an open file descriptor execl() --Executes a file execle() -- Executes a file execlp() -- Executes a file execv() -- Executes a file execve() -- Executes a file execvp() -- Executes a file exit() -- Causes normal program termination _exit() -- Terminates a process exp() -- Computes the exponential function fabs() -- Computes the absolute-value function fclose() -- Closes an open stream fcntl() -- Manipulates an open file descriptor fdopen() -- Opens a stream on a file descriptor feoff() -- Tests the end-of-file indicator for a stream ferror() -- Tests the error indicator for a stream fflush() -- Updates stream fgetc() -- Reads a character from a stream fgetpos() -- Gets the current file position fgets() -- Reads n characters from a stream fileno() -- Maps a stream pointer to a file descriptor floor() -- Computes the largest integer not greater than x fmod() -- Computes the remainder of x/y fopen() -- Opens a stream fork() -- Creates a process fpathconf() -- Gets configuration variable for an open file fprintf() -- Writes formatted text to a stream fputc() -- Writes a character to a stream fputs() -- Writes a string to a stream fread() -- Reads an array from a stream free() -- Deallocates dynamic memory freopen() -- Closes and then opens a stream frexp() -- Breaks a floating-point number into a fraction and integer fscanf() -- Reads formatted input from a stream fseek() -- Sets file position fsetpos() -- Sets the file position for a stream fstat() -- Gets file status ftell() -- Gets the position indicator for a stream fwrite() -- Writes an array to a stream getc() -- Reads a character from a stream getchar() -- Reads a character from standard input getcwd() -- Gets current working directory getegid() -- Gets effective group ID getenv() -- Gets the environment variable geteuid() -- Gets effective user ID getgid() -- Gets real group ID getgrgid() -- Reads groups database based on group ID getgrnam() -- Reads group database based on group name getgroups() -- Gets supplementary group IDs getlogin() -- Gets user name getpgrp() -- Gets process group ID getpid() -- Gets process ID getppid() -- Gets parent process ID getpwnam() -- Reads user database based on user name getpwuid() -- Reads user database based on user ID gets() -- Reads a string from standard input getuid() -- Gets real user ID gmtime() -- Breaks down a timer value into a time structure in Coordinated Universal Time (UTC) isalnum() -- Tests for alphabetic or numeric character isalpha() -- Tests for alphabetic character isatty() -- Determines if a file descriptor is associated with a terminal iscntrl() -- Tests for control character isdigit() -- Tests for decimal-digit character isgraph() -- Tests for printing character islower() -- Tests for lowercase character isprint() -- Tests for printing character ispunct() -- Tests for punctuation isspace() -- Tests for white-space character isupper() -- Tests for uppercase alphabetic character isxdigit() -- Tests for hexadecimal-digit character kill() -- Sends a signal to a process labs() -- Computes the absolute value of a long integer ldexp() -- Multiplies a floating-point number by a power of 2 ldiv() -- Computes the quotient and remainder of integer division link() -- Creates a link to a file localeconv() -- Gets rules to format numeric quantities for the current locale localtime() -- Breaks down a timer value into a time structure in local time log() -- Computes the natural log function log10() -- Computes the base-ten logarithm function longjmp() -- Restores the calling environment lseek() -- Repositions read/write file offset malloc() -- Allocates dynamic memory mblen() -- Determines the number of bytes in a character mbstowcs() -- Converts a multibyte string to a wide-character string mbtowc() -- Converts a multibyte character to a wide character memchr() -- Scans memory for a byte memcmp() -- Compares two memory objects memcpy() -- Copies non-overlapping memory objects memmove() -- Copies (possibly overlapping) memory objects memset() -- Fills memory with a constant byte mkdir() -- Makes a directory mkfifo() -- Makes a FIFO special file mktime() -- Converts time formats modf() -- Breaks a value into integral and fractional parts open() -- Opens a file opendir() -- Opens a directory pathconf() -- Gets configuration variables for a path pause() -- Suspends process execution perror() -- Prints an error message pipe() -- Creates an interprocess channel pow() -- Computes x raised to the power y printf() -- Writes formatted text to the standard output stream putc() -- Writes a character to a stream putchar() -- Writes a character to standard output puts() -- Writes a string to standard output qsort() -- Sorts an array raise() -- Sends a signal rand() -- Returns a random number read() -- Reads from a file readdir() -- Reads a directory realloc() -- Changes the size of a memory object remove() -- Removes a file from a directory rename() -- Renames a file rewind() -- Sets the file position to the beginning of the file rewinddir() -- Resets the readdir() pointer rmdir() -- Removes a directory scanf() -- Reads formatted text from standard input stream setbuf() -- Determines how a stream will be buffered setgid() -- Sets group ID setjmp() -- Saves the calling environment for use by longjmp() setlocale() -- Sets or queries a programUs locale setpgid() -- Sets process group ID for job control setsid() -- Creates a session and sets the process group ID setuid() -- Sets the user ID setvbuf() -- Determines buffering for a stream sigaction() -- Examines and changes signal action sigaddset() -- Adds a signal to a signal set sigdelset() --Removes a signal from a signal set sigemptyset() -- Creates an empty signal set sigfillset() -- Creates a full set of signals sigismember() -- Tests a signal set for a selected member siglongjmp() -- Goes to and restores signal mask signal() -- Specifies signal handling sigpending() -- Examines pending signals sigprocmask() --Examines and changes blocked signals sigsetjmp() -- Saves state for siglongjmp() sigsuspend() -- Waits for a signal sin() -- Computes the sine function sinh() -- Computes the hyperbolic sine of x sleep() -- Delays process execution sprintf() -- Formats a string sqrt() -- Computes the square root function srand() -- Sets a seed for the rand() function sscanf() -- Parses a string stat() -- Gets information about a file strcat() -- Concatenates two strings strchr() -- Scans a string for a character strcmp() -- Compares two strings strcoll() -- Compares two strings using the current locale strcpy() -- Copies a string strcspn() -- Searches a string for characters which are not in the second string strerror() -- Converts an error number to a string strftime() -- Formats date/time strlen() -- Computes the length of a string strncat() -- Concatenates two counted strings strncmp() -- Compares two counted strings strncpy() -- Copies a counted string strpbrk() -- Searches a string for any of a set of characters strrchr() -- Locates the last occurrence of a character in a string strspn() -- Searches a string for any of a set of characters strstr() -- Locates a substring strtod() -- Converts a string to double strtok() -- Breaks a string into tokens strtol() -- Converts a string to long int strtoul() -- Converts a string to unsigned long int strxfrm() -- Transforms strings using rules for locale sysconf() -- Gets system configuration information system() -- Executes a command tan() -- Computes the tangent of x tanh() -- Computes the hyperbolic tangent of x tcdrain() -- Waits for all output to be transmitted to the terminal tcflow() -- Suspends/restarts terminal output tcflush() -- Discards terminal data tcgetattr() -- Gets terminal attributes tcgetpgrp() -- Gets foreground process group ID tcsendbreak() -- Sends a break to a terminal tcsetattr() -- Sets terminal attributes tcsetpgrp() -- Sets foreground process group ID time() -- Determines the current calendar time times() -- Gets process times tmpfile() -- Creates a temporary file tmpnam() -- Generates a string that is a valid non-existing file name tolower() -- Converts uppercase to lowercase toupper() -- Converts lowercase to uppercase ttyname() -- Determines a terminal pathname tzset() -- Sets the timezone from environment variables umask() -- Sets a file creation mask uname() -- Gets system name ungetc() -- Pushes a character back onto a stream unlink() -- Removes a directory entry utime() -- Sets file access and modification times va_arg() -- Gets the next argument va_end() -- Ends variable argument list va_start() -- Starts a variable argument list vfprintf() -- Writes formatted text with a variable argument list vprintf() -- Write formatted text to standard output with a variable argument list vsprintf() -- Write formatted text to a string with a variable argument list wait() -- Waits for process termination waitpid() -- Waits for process termination wcstombs() -- Converts a wide character string to a multibyte character string wctomb() -- Converts a wide character to a multibyte character write() -- Writes to a file APPENDIX A Header Files Description of Tables APPENDIX B Data Structures APPENDIX C Error Codes APPENDIX D Porting from BSD and System V BSD Functions System V Functions APPENDIX E Changes and Additions in Standard C Preprocessor Character Set Identifiers Keywords Operators Strings Constants Structures, Unions, and Arrays switch Statements Headers Pointers Functions Arithmetic APPENDIX F Federal Information Processing Standard 151-1 APPENDIX G Answers to Selected Exercises Related Publications The Standards Other Documents of Interest Index

Additional information

CIN0937175730G
9780937175736
0937175730
POSIX Programmer's Guide by Donald Lewine
Used - Good
Hardback
O'Reilly Media
19910423
640
N/A
Book picture is for illustrative purposes only, actual binding, cover or edition may vary.
This is a used book - there is no escaping the fact it has been read by someone else and it will show signs of wear and previous use. Overall we expect it to be in good condition, but if you are not entirely satisfied please get in touch with us

Customer Reviews - POSIX Programmer's Guide