Advanced Programming in the UNIX Environment - PowerPoint PPT Presentation

1 / 8
About This Presentation
Title:

Advanced Programming in the UNIX Environment

Description:

Daewoo Lee. 2 / 8. Advanced Programming in the UNIX Environment. Programs and Processes. Program ... Process ID : unique nonnegative integer identifier of each ... – PowerPoint PPT presentation

Number of Views:455
Avg rating:3.0/5.0
Slides: 9
Provided by: daewo
Category:

less

Transcript and Presenter's Notes

Title: Advanced Programming in the UNIX Environment


1
Advanced Programmingin the UNIX Environment
  • Chap 1. Introduction
  • 2003. 5. 1
  • Daewoo Lee

2
Programs and Processes
  • Program
  • An executable file residing in a disk file
  • Process
  • An executing instance of a program
  • Process ID unique nonnegative integer
    identifier of each process
  • Process Control
  • fork
  • exec
  • waitpid

3
Process Control (1/2)
  • fork
  • To create a new process
  • parent(caller), child(callee)
  • Return value
  • To parent pID of the new child
  • To child 0
  • Called once but returns twice.
  • exec
  • To execute the new program file
  • Replace the current process with the new program
  • 6 variants
  • execl, execlp, execle, execv, execvp, execve

4
Process Control (2/2)
  • fork exec
  • Spawning a new process
  • waitpid
  • To wait for some process to terminate
  • Return the termination status to the 2nd
    argument.

5
ANSI C Features
  • Primitive System Data Types
  • ex. pid_t, size_t,
  • ltsys/types.hgt
  • To prevent from using specific data types
  • To allow each implementation to choose a suitable
    data type
  • Necessary to modify one header

6
Error Handling
  • When an error occurs
  • A negative value is often returned.
  • Additional information
  • lterrno.hgt extern int errno
  • errno
  • Never cleared if an error doesnt occur.
  • Never set to 0.
  • strerror, perror

7
Signals
  • Signals
  • To notify a process that some condition has
    occurred
  • When a signal is received, the process can
  • ignore the signal.
  • let the default action occur.
  • provide a function that is called when the signal
    occurs.
  • signal catch the specific signal

8
System Calls and Library Functions
Application Code
more elaborate interface
user process
C Library Functions
minimal interface
kernel
Write a Comment
User Comments (0)
About PowerShow.com