encontra o processo 0 na árvore ps

0

Eu li a seguinte frase de uma instrução

Process ID 0 is usually the scheduler process and is often known as the swapper. No program on disk corresponds to this process, which is part of the kernel and is known as a system process. Process ID 1 is usually the init process and is invoked by the kernel at the end of the bootstrap procedure.

Verifique os processos:

$ pstree -p $$ 
-+= 00001 root /sbin/launchd
 \-+= 00264 me /Applications/Utilities/Terminal.app/Contents/MacOS/Terminal -psn_0_53261
   \-+= 00365 root login -pfl me /bin/bash -c exec -la bash /usr/local/bin/bash
     \-+= 00366 me -bash
       |-+= 06305 me pstree -p 366
       | \--- 06307 root ps -axwwo user,pid,ppid,pgid,command

Poderia encontrar o processo 1, mas onde está o processo 0?

    
por JawSaw 15.11.2018 / 03:48

1 resposta

2

O BSD ps não mostra o PID 0:

$ ps -o pid,ppid,comm -p 0,1,$$
  PID  PPID COMM
    1     0 /sbin/launchd
14705 14704 -zsh

Como pstree usa ps para obter informações de processo (como você pode ver na sua saída), obviamente não é possível mostrar o PID 0.

Use top ou Activity Manager no OSX para ver o PID 0:

$ top -l1 -pid 0
Processes: 480 total, 2 running, 478 sleeping, 2777 threads
2018/11/15 12:20:36
Load Avg: 1.99, 2.21, 2.13
CPU usage: 6.59% user, 18.33% sys, 75.7% idle
SharedLibs: 207M resident, 50M data, 40M linkedit.
MemRegions: 135141 total, 7727M resident, 63M private, 2624M shared.
PhysMem: 16G used (6717M wired), 61M unused.
VM: 3304G vsize, 1297M framework vsize, 5481932(0) swapins, 6319905(0) swapouts.
Networks: packets: 2367177/1916M in, 1966560/789M out.
Disks: 2569936/63G read, 1879985/62G written.

PID COMMAND     %CPU TIME     #TH   #WQ #PORTS MEM  PURG CMPRS PGRP PPID STATE   BOOSTS %CPU_ME %CPU_OTHRS UID FAULTS  COW MSGSENT   MSGRECV   SYSBSD SYSMACH CSW        PAGEINS IDLEW    POWER INSTRS CYCLES USER #MREGS RPRVT VPRVT VSIZE KPRVT KSHRD
0   kernel_task 0.0  47:24.02 211/8 0   0      71M+ 0B   0B    0    0    running  0[0]  0.00000 0.00000    0   400853+ 0   82636075+ 75828596+ 0      0       295335075+ 0       14150823 0.0   0      0      root N/A    N/A   N/A   N/A   N/A   N/A
    
por 15.11.2018 / 04:23

Tags