chapter 8 exceptional control flow envp25 userdroh

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: r-handling and the error-handling wrappers used throughout the book. The wrappers are defined in a file called csapp.c and their prototypes are defined in a header file called csapp.h. For your reference, Appendix A provides the sources for these files. 8.4 Process Control Unix provides a number of system calls for manipulating processes from C programs. This section describes the important functions and gives examples of how they are used. 404 CHAPTER 8. EXCEPTIONAL CONTROL FLOW 8.4.1 Obtaining Process ID’s Each process has a unique positive (non-zero) process ID (PID). The getpid function returns the PID of the calling process. The getppid function returns the PID of its parent (i.e., the process that created the calling process). #include <unistd.h> #include <sys/types.h> pid t getpid(void); pid t getppid(void); returns: PID of either the caller or the parent The getpid and getppid routines return an integer value of type pid t, which on Linux systems is defined in types.h as an int. 8.4.2 Creating and Terminating Processes From a programmer’s perspective, we can think of a process as being in one of three states: ¯ ¯ ¯ Running. The process is either executing on the CPU, or is waiting to be execute...
View Full Document

Ask a homework question - tutors are online