Microsoft PowerPoint - chap9 [호환 모드]

Similar documents
6주차.key

Chap04(Signals and Sessions).PDF

제9장 프로세스 제어

<C0CCBCBCBFB52DC1A4B4EBBFF82DBCAEBBE7B3EDB9AE2D D382E687770>

10.

슬라이드 1

Microsoft PowerPoint - 10_Process

ABC 11장

Remote UI Guide

System Programming Lab

untitled

제1장 Unix란 무엇인가?

제1장 Unix란 무엇인가?

Chap06(Interprocess Communication).PDF

PowerPoint 프레젠테이션

강의10

SMB_ICMP_UDP(huichang).PDF

휠세미나3 ver0.4

chapter4

<4D F736F F F696E74202D FC7C1B7CEBCBCBDBA20BBFDBCBAB0FA20BDC7C7E0205BC8A3C8AF20B8F0B5E55D>

2009년 상반기 사업계획

<C1A63130C0E5C7C1B7CEBCBCBDBA2E687770>

Microsoft PowerPoint - 10_Signal

ETL_project_best_practice1.ppt

좀비프로세스 2

/chroot/lib/ /chroot/etc/

2-11Àå

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

PWR PWR HDD HDD USB USB Quick Network Setup Guide xdsl/cable Modem PC DVR 1~3 1.. DVR DVR IP xdsl Cable xdsl Cable PC PC DDNS (

PowerPoint 프레젠테이션

Microsoft PowerPoint - ch09_파이프 [호환 모드]

2009년 상반기 사업계획


°í¼®ÁÖ Ãâ·Â

Microsoft PowerPoint - ch03ysk2012.ppt [호환 모드]

Sena Device Server Serial/IP TM Version

<32B1B3BDC32E687770>

1217 WebTrafMon II

PowerPoint Presentation

11¹Ú´ö±Ô

1장. 유닉스 시스템 프로그래밍 개요

4 CD Construct Special Model VI 2 nd Order Model VI 2 Note: Hands-on 1, 2 RC 1 RLC mass-spring-damper 2 2 ζ ω n (rad/sec) 2 ( ζ < 1), 1 (ζ = 1), ( ) 1

0125_ 워크샵 발표자료_완성.key

SRC PLUS 제어기 MANUAL

Something that can be seen, touched or otherwise sensed

Microsoft PowerPoint - 09-Pipe

MAX+plus II Getting Started - 무작정따라하기

13주-14주proc.PDF

T100MD+

Solaris Express Developer Edition

USB USB DV25 DV25 REC SRN-475S REC SRN-475S LAN POWER LAN POWER Quick Network Setup Guide xdsl/cable Modem PC DVR 1~3 1.. DVR DVR IP xdsl Cable xdsl C

step 1-1

CD-RW_Advanced.PDF

Assign an IP Address and Access the Video Stream - Installation Guide

ORANGE FOR ORACLE V4.0 INSTALLATION GUIDE (Online Upgrade) ORANGE CONFIGURATION ADMIN O

목차 BUG offline replicator 에서유효하지않은로그를읽을경우비정상종료할수있다... 3 BUG 각 partition 이서로다른 tablespace 를가지고, column type 이 CLOB 이며, 해당 table 을 truncate

Microsoft Word - Automap3


chap12(process).hwp

PowerPoint 프레젠테이션

PowerPoint 프레젠테이션

Microsoft PowerPoint - Lecture_Note_7.ppt [Compatibility Mode]

MPLAB C18 C

untitled

PowerPoint 프레젠테이션

슬라이드 1

리눅스 프로세스 관리

슬라이드 1

소개 TeraStation 을 구입해 주셔서 감사합니다! 이 사용 설명서는 TeraStation 구성 정보를 제공합니다. 제품은 계속 업데이트되므로, 이 설명서의 이미지 및 텍스트는 사용자가 보유 중인 TeraStation 에 표시 된 이미지 및 텍스트와 약간 다를 수

Motor

2009년 상반기 사업계획

untitled

(SW3704) Gingerbread Source Build & Working Guide

Microsoft Word - KPMC-400,401 SW 사용 설명서

Sena Technologies, Inc. HelloDevice Super 1.1.0

슬라이드 1

(Asynchronous Mode) ( 1, 5~8, 1~2) & (Parity) 1 ; * S erial Port (BIOS INT 14H) - 1 -

untitled


MySQL-Ch10

<4D F736F F F696E74202D BDC3B1D7B3CEB0FA20BDC3B1D7B3CE20C3B3B8AE2E707074>

APOGEE Insight_KR_Base_3P11

IKC43_06.hwp

untitled

untitled

Backup Exec

,,,,,, (41) ( e f f e c t ), ( c u r r e n t ) ( p o t e n t i a l difference),, ( r e s i s t a n c e ) 2,,,,,,,, (41), (42) (42) ( 41) (Ohm s law),

8 장데이터베이스 8.1 기본개념 - 데이터베이스 : 데이터를조직적으로구조화한집합 (cf. 엑셀파일 ) - 테이블 : 데이터의기록형식 (cf. 엑셀시트의첫줄 ) - 필드 : 같은종류의데이터 (cf. 엑셀시트의각칸 ) - 레코드 : 데이터내용 (cf. 엑셀시트의한줄 )

슬라이드 제목 없음

Interstage5 SOAP서비스 설정 가이드

10주차.key

USER GUIDE

DBPIA-NURIMEDIA

<32382DC3BBB0A2C0E5BED6C0DA2E687770>

디지털포렌식학회 논문양식

UDP Flooding Attack 공격과 방어

PowerChute Personal Edition v3.1.0 에이전트 사용 설명서

C++-¿Ïº®Çؼ³10Àå

Page 2 of 5 아니다 means to not be, and is therefore the opposite of 이다. While English simply turns words like to be or to exist negative by adding not,

Transcription:

제 9 장프로세스관계 숙대창병모 1

Contents 1. Logins 2. Process Groups 3. Sessions 4. Controlling Terminal 5. Job Control 숙대창병모 2

로그인 숙대창병모 3

터미널로그인 /etc/ttys: 1 line per terminal device getty: opens terminal device for reading and writing gettytab: data file for getty login: login program getpass: read password crypt: encrypts plain text (password) 숙대창병모 4

터미널로그인과정 process ID 1 init init fork exec getty /reads/etc/ttys; y; forks once per terminal; create empty environment; each child execs ecs getty 숙대창병모 5

로그인후상태 process ID 1 init init fork exec getty exec login /reads/etc/ttys; forks once per terminal; create empty environment; each child execs getty open terminal device (file descriptors 0, 1, 2); reads user name; initial environment set 숙대창병모 6

네트워크로그인 inetd - Internet superserver waits for TCP/IP connection requests when request arrives, does a fork and exec of the appropriate program telnet a remote login application(client) that uses TCP/IP protocol. telnetd TELNET server opens pseudo-terminal device splits into two processes using fork The parent handles the communication across the network connection The child does an exec of the login program. 숙대창병모 7

TELNET 서버 TCP connection request from TELNET client process ID 1 init inetd fork inetd exec telnetd fork /exec of /bin/sh which executes shell script /etc/rc when system comes up multiuser when connection request arrives from TELNET client 숙대창병모 8

프로세스그룹 숙대창병모 9

프로세스그룹 프로세스 IDs Process ID(PID) Process Group ID(GID) 각프로세스는하나의프로세스그룹에속함. 각프로세스는자신이속한 process group ID를가지며 fork 시물려받는다. #include <sys/types.h> #include <unistd.h> pid_t getpgrp(void); p Returns: process GID of calling process 숙대창병모 10

프로세스그룹 프로세스그룹이란? 통상한부모 ( 그룹리더 ) 가생성하는자손프로세스들이하나의프로세스그룹을형성한다. Each process group has a process group leader Process GID = PID 프로세스그룹은무엇을하는데사용되나요? 프로세스그룹은주로 signal 전달등을위해설정됨 kill -INT -3245 명령은프로세스그룹 3245 에 SIGINT 보냄 kill -INT 3245 명령은프로세스 3245에만 SIGINT 보냄 숙대창병모 11

프로세스그룹 : 예 #include <sys/types.h> #include <unistd.h> main() { int pid, gid; printf("parent: PID = %d GID = %d\n", getpid(), getpgrp()); pid = fork(); if (pid == 0) { // 자식프로세스 printf("child: PID = %d GID = %d\n", getpid(), getpgrp()); } } 숙대창병모 12

프로세스그룹 프로세스그룹만들기 자식프로세스는 setpgrp 호출을통하여기존의프로세스그룹에서벗어나서새로운프로세스그룹을형성할수있다. A process can create a new process group and become leader int setpgid(pid_t t pid, pid_t pgid); A process group leader can create processes in the group 프로세스그룹소멸 the last process terminates OR joins another process group (leader may terminate first) 숙대창병모 13

Process Groups #include <sys/types.h> #include <unistd.h> int setpgid(pid_t pid, pid_t pgid); Returns: 0 if OK, -1 on error 역할 Create new group or join existing group. Set the process GID of the process pid to pgid. pid == pgid leader pid!= pgid pid becomes a member of the process group pid == 0 PID of caller 사용 pgid == 0 pid 가 process group leader 됨 Process can set PGID of itself or its children 숙대창병모 14

Example #include <sys/types.h> #include <unistd.h> main() { int pid, gid; printf( PARENT: PID = %d GID = %d \n, getpid(), getpgrp()); pid = fork(); if (pid == 0) { setpgid(0, 0); printf( CHILD: PID = %d GID = %d \n, getpid(), getpgrp()); } } 숙대창병모 15

세션 / 컨트롤터미널 숙대창병모 16

세션 login shell process group proc1 proc2 proc3 proc4 process group proc5 session process group 세션이란? 예 Collection of one or more process groups Job 제어에사용된다. $proc1 proc2 & $proc3 proc4 proc5 숙대창병모 17

Sessions #include <sys/types.h> #include <unistd.h> pid_t setsid(void); Returns: PGID if OK, -1 on error 새로운세션만들기 A process (not a process group leader) creates a new session The process becomes session leader (new session contains this process only) The process become process group leader of a new process group (PGID=PID) 숙대창병모 18

컨트롤터미널 세션을컨트롤할수있는터미널 A session can have a controlling terminal The session leader is the controlling process 세션내의프로세스그룹들 1 foreground, 1 or more backgrounds 이 foreground group 이입력을받는다. 컨트롤터미널로부터키보드입력및 signal 받음 Interrupt key from control terminal SIGINT to all foreground processes 숙대창병모 19

컨트롤터미널 session login shell proc1 proc2 proc3 proc4 background process group session leader = controlling process background process group proc5 foreground process group network disconnect (hangup signal) controlling terminal terminal input and terminal-generated signals 숙대창병모 20

init or inetd Job Control getty or telnetd login exec login shell change in status of children setpgid setpgid exec, after setsid, then establishing controlling terminal change in status of children background process group(s) tcsetpgrp to set process group for controlling terminal write to terminal may generate SIGTTOU terminal input/output foreground process group Read from terminal generate SIGTTIN terminal driver user at a terminal terminal-generated signals (SIGINT, SIGQUIT, SIGSTP) delivered to process group 숙대창병모 21

Job Control 숙대창병모 22

Job Control A feature added by Berkeley in 1980 Job A group of processes To start multiple jobs from a single terminal To control: which jobs can access terminal which jobs are to run in background. 숙대창병모 23

Job Control 3 forms of support required by job control: A shell to support job control Terminal driver must support job control Job-control signals Example cat /etc/passwd grep faculty sort > faculty.out & 2 background ls l grep test sort > test.out & jobs vi main.c 1 foreground job 숙대창병모 24

Shell for Job Control Shells assign a job ID to a background job $cat /etc/passwd grep faculty sort > faculty.out & [1] 19277 19278 19279 $ls l grep test sort > test.out & [2] 19280 19281 19282 $ [2] + Done cat /etc/passwd grep & [1] + Done ls l grep test & job number process IDs 숙대창병모 25

Terminal Driver for Job Control Terminal driver looks out for 3 special characters: Interrupt character (DELETE or CTRL-C) generates SIGINT Quit character (CTRL-BACKSLASH) generates SIGQUIT Suspend character (CTRL-Z) generates SIGTSTP SIGTTIN (1) When background job tries to read from the terminal, (2) the terminal driver sends it to the background job (3) This stops the background job. SIGTTOU (stty tostop 했을경우에 ) (1) When background job tries to write to the terminal, (2) the terminal driver sends it to the background job (3) This stops the background job. 숙대창병모 26

Job Control $ cat > temp.foo & [1] 1719 $ [1] + Stopped(tty 입력 ) cat>temp.foo & $ fg %1 cat> temp.foo hello, world ^D $cat temp.foo hello, world 숙대창병모 27

Job Control $ cat temp.foo & [1] 1719 $ hello, world [1] + Done cat temp.foo & $ stty tostop $ cat temp.foo & [1] 1721 $ [1] + Stopped(tty output) cat temp.foo & $ fg %1 cat temp.foo hello, world 숙대창병모 28

Job Control fg command The shell places the job into the foreground process group, and sends SIGCONT to the process group stty command stty tostop disable ability of background jobs to output to the controlling terminal 숙대창병모 29

init or inetd Job Control getty or telnetd login exec login shell change in status of children setpgid setpgid exec, after setsid, then establishing controlling terminal change in status of children background process group(s) tcsetpgrp to set process group for controlling terminal write to terminal may generate SIGTTOU terminal input/output foreground process group Read from terminal generate SGITTIN terminal driver user at a terminal terminal-generated signals (SIGINT, SIGQUIT, SIGSTP) delivered to process group 숙대창병모 30