Daemon 데몬 프로세스

zuckerfrei·2024년 2월 16일
0

Linux

목록 보기
7/7

사전지식

PID

PID(Process ID)는 운영체제에서 프로세스를 식별하기 위해 프로세스에 부여하는 번호를 의미한다.

PPID

PPID(Parent Process ID)는 부모 프로세스의 PID를 의미한다.

만일 부모 프로세스가 자식 프로세스보다 일찍 종료되는 경우 자식 프로세스는 고아 프로세스가 되어 PPID로 init process의 PID(1)를 가지게 된다.


데몬 프로세스

  • 백그라운드 프로세스 중에서 부모프로세스(PPID)가 1init 혹은 다른 데몬프로세스인 프로세스
    • 모든 백그라운드 프로세스가 데몬인 것은 아니다
      • 백그라운드 프로세스라면, 부모프로세스가 중지될 경우 그 프로세스도 종료됨
      • 데몬프로세스라면 부모프로세스가 init 1이거나 다른 데몬프로세스

예시)

[admin@dev-server ~]$ ps -ef | grep postgres
UID        PID  PPID  C STIME TTY          TIME CMD
postgres  4202     1  0 Sep02 ?        00:02:26 /usr/pgsql-12/bin/postmaster -D /data/
postgres  4204  4202  0 Sep02 ?        00:00:00 postgres: logger
postgres  4206  4202  0 Sep02 ?        00:00:04 postgres: checkpointer
postgres  4207  4202  0 Sep02 ?        00:00:05 postgres: background writer
postgres  4208  4202  0 Sep02 ?        00:00:07 postgres: walwriter
postgres  4209  4202  0 Sep02 ?        00:00:06 postgres: autovacuum launcher
postgres  4210  4202  0 Sep02 ?        00:00:38 postgres: stats collector
postgres  4211  4202  0 Sep02 ?        00:00:00 postgres: logical replication launcher
postgres 12128  4202  0 18:11 ?        00:00:00 postgres: user db-name 192.168.130.16(44130) idle
postgres 13918  4202  0 18:28 ?        00:00:00 postgres: user db-name  192.168.20.6(36584) idle
postgres 13919  4202  0 18:28 ?        00:00:00 postgres: user db-name  192.168.20.6(36586) idle
postgres 13920  4202  0 18:28 ?        00:00:00 postgres: user db-name  192.168.20.6(36588) idle
  • PID 4202 프로세스는 PID 1을 부모프로세스로 가짐
  • PID 4204~4211 프로세스는 PID 4202를 부모프로세스로 가짐
  • PID 12128~13920 프로세스는 PID 4202를 부모프로세스로 가짐
  • 이렇게 PPID가 1인 postgres 프로세스와 PPID가 1인 프로세스를 PPID로 갖는 나머지 프로세스들(4204~13920)이 데몬 프로세스임
  • 이 데몬 프로세스들은 로그인한 SSH 세션에서 exit로 로그아웃 하더라도 종료되지 않음
profile
무설탕 음료를 좋아합니다

0개의 댓글