Pid что это windows

From Wikipedia, the free encyclopedia

In computing, the process identifier (a.k.a. process ID or PID) is a number used by most operating system kernels—such as those of Unix, macOS and Windows—to uniquely identify an active process. This number may be used as a parameter in various function calls, allowing processes to be manipulated, such as adjusting the process’s priority or killing it altogether.

In Unix-like operating systems, new processes are created by the fork() system call. The PID is returned to the parent process, enabling it to refer to the child in further function calls. The parent may, for example, wait for the child to terminate with the waitpid() function, or terminate the process with kill().

There are two tasks with specially distinguished process IDs: PID 0 is used for swapper or sched, which is part of the kernel and is a process that runs on a CPU core whenever that CPU core has nothing else to do.[1] Linux also calls the threads of this process idle tasks.[2] In some APIs, PID 0 is also used as a special value that always refers to the calling thread, process, or process group.[3][4] Process ID 1 is usually the init process primarily responsible for starting and shutting down the system. Originally, process ID 1 was not specifically reserved for init by any technical measures: it simply had this ID as a natural consequence of being the first process invoked by the kernel. More recent Unix systems typically have additional kernel components visible as ‘processes’, in which case PID 1 is actively reserved for the init process to maintain consistency with older systems.

Process IDs, in the first place, are usually allocated on a sequential basis,[5] beginning at 0 and rising to a maximum value which varies from system to system. Once this limit is reached, allocation restarts at 300 and again increases. In macOS and HP-UX, allocation restarts at 100.[6] However, for this and subsequent passes any PIDs still assigned to processes are skipped. Some consider this to be a potential security vulnerability in that it allows information about the system to be extracted, or messages to be covertly passed between processes. As such, implementations that are particularly concerned about security may choose a different method of PID assignment.[7] On some systems, like MPE/iX, the lowest available PID is used, sometimes in an effort to minimize the number of process information kernel pages in memory.

The current process ID is provided by a getpid() system call,[8] or as a variable $$ in shell. The process ID of a parent process is obtainable by a getppid() system call.[9]

On Linux, the maximum process ID is given by the pseudo-file /proc/sys/kernel/pid_max.[10]

Some processes, for example, the moc music player and the MySQL daemon, write their PID to a documented file location, to allow other processes to look it up.[citation needed]

On the Windows family of operating systems, one can get the current process’s ID using the GetCurrentProcessId() function of the Windows API,[11] and ID of other processes using GetProcessId().[12] Internally, process ID is called a client ID, and is allocated from the same namespace as thread IDs, so these two never overlap. The System Idle Process is given process ID 0. The System Process is given the process ID 8 on Windows 2000 and 4 on Windows XP and Windows Server 2003.[13] On the Windows NT family of operating systems, process and thread identifiers are all multiples of 4, but it is not part of the specification.[14]

  • User identifier (UID)
  • Group identifier (GID)
  • Thread identifier (TID)
  • Handle (computing)
  • Program Segment Prefix (PSP)
  1. ^ What is PID 0?
  2. ^ Linux kernel code: tools/perf/builtin-sched.c, pid 0 == swapper == idle task
  3. ^ kill(2) — Linux manual page
  4. ^ sched_setscheduler(2) — Linux manual page
  5. ^ pid_namespaces(7) — Linux manual page
  6. ^ «What’s the maximum pid for Mac OS X?». Ask Different. Retrieved 2024-11-02.
  7. ^ comp.unix.aix Frequently Asked Questions, retrieved 2008-07-21
  8. ^ «getpid», The Open Group Base Specifications Issue 7, 2018 edition
  9. ^ «getppid», The Open Group Base Specifications Issue 7, 2018 edition
  10. ^ «proc — process information pseudo-filesystem», Linux Programmer’s Manual, retrieved 2009-12-28
  11. ^ «GetCurrentProcessId Function», Windows Dev Center, Microsoft, 5 December 2018
  12. ^ «GetProcessId function», Windows Dev Center, Microsoft, 5 December 2018
  13. ^ Russinovich, Mark; David A. Solomon (2005), «Chapter 2: System Architecture», Microsoft Windows Internals (4th ed.), Microsoft Press, p. 76, ISBN 0-7356-1917-4
  14. ^ Chen, Raymond (2008-02-28), «Why are process and thread IDs multiples of four?», The Old New Thing, Microsoft

Как узнать идентификатор процесса (PID или ИД…

Статья обновлена: 31 октября 2023
ID: 6325

Вы можете узнать идентификатор процесса (PID или ИД процесса) с помощью Диспетчера задач или командной строки.

Как узнать PID c помощью Диспетчера задач

Как узнать PID c помощью командной строки

Спасибо за ваш отзыв, вы помогаете нам становиться лучше!

Спасибо за ваш отзыв, вы помогаете нам становиться лучше!

Каждый запущенный процесс в Windows имеет свой числовой идентификатор — PID или ИД процесса, который может использоваться для обращения к конкретному процессу, например, для получения информации о нём или принудительного закрытия.

В этой инструкции несколько способов узнать PID процесса в Windows 11 или Windows 10, большинство из которых подойдут и для предыдущих версий системы.

ИД процесса в диспетчере задач

Быстрый и простой способ посмотреть PID процесса в графическом интерфейсе — использовать диспетчер задач Windows, для этого:

  1. Откройте диспетчер задач: вы можете использовать контекстное меню кнопки «Пуск», нажать клавиши Ctrl+Shift+Esc или использовать меню Ctrl+Alt+Delete для этого.
  2. В диспетчере задач переключитесь на вкладку «Сведения» (в Windows 11, переключение выполняется в меню) или «Подробности» (в Windows 10).
    Просмотр PID процесса в диспетчере задач Windows 11

  3. Обратите внимание на столбец «ИД процесса» — это и есть нужный PID. Если столбец не отображается, нажмите по заголовку таблицы с процессами правой кнопкой мыши и используйте пункт «Выбрать столбцы», чтобы включить показ нужного столбца.
    Просмотр PID процесса в диспетчере задач Windows 10

Для большинства пользователей этого метода будет достаточно для получения нужной информации.

Однако, если узнать PID запущенного процесса требуется при выполнении какого-либо пользовательского скрипта, могут пригодиться описанные в последней части инструкции методы его получения без использования графического интерфейса — в командной строке или PowerShell.

PID процесса в Мониторе ресурсов

Ещё один метод, очень похожий на предыдущий — использование встроенного инструмента «Монитор ресурсов»:

  1. Нажмите клавиши Win+R на клавиатуре, либо нажмите правой кнопкой мыши по кнопке «Пуск» и выберите пункт «Выполнить».
  2. Введите resmon в диалоговое окно «Выполнить» и нажмите Enter.
  3. Откроется окно «Монитор ресурсов» в нем, на вкладке «Обзор» вы увидите список процессов, распределенных по группам (использование ЦП, Диска, Сети и Памяти) с указанием их ИД в соответствующем столбце.
    ИД процессов в Мониторе ресурсов Windows

Process Explorer

Process Explorer — «продвинутый» диспетчер задач из Microsoft Sysinternals, скачать его можно как в комплекте с другими утилитами, так и отдельно с официального сайта.

PID в Process Explorer

После запуска утилиты, информацию о PID процесса вы сможете найти в одноименном столбце.

Командная строка

Получить PID процесса можно с помощью команд командной строки. Шаги будут следующими:

  1. Запустите командную строку, лучше — от имени администратора (как это сделать).
  2. Чтобы получить список всех процессов, включая информацию об их PID, введите команду
    tasklist

    и нажмите Enter.

    Просмотр PID процессов в командной строке

  3. Для отображения только процессов с заданными именами файлов (в имени допустимы wildcard-символы, например, *) можно использовать следующую команду:
    tasklist /FI "IMAGENAME eq имя_файла.exe"
    Получить ИД процесса по имени в командной строке

  4. Вы можете вывести результат выполнения команды в текстовый файл, пример:
    tasklist > C:\pid.txt

С помощью tasklist можно отфильтровать процессы и по другим свойствам, например, получить список только зависших программ, подробнее на тему получения списка не отвечающих программ — в этой статье.

Windows PowerShell или Терминал Windows

И ещё одна возможность для получения PID процессов — использование терминала Windows или PowerShell:

  1. Запустите Windows PowerShell или Терминал Windows, для этого можно использовать меню по правому клику на кнопке «Пуск».
  2. Базовый вариант команды:
    Get-Process

    выдаст список всех процессов, PID будет отображен в столбце Id

    Просмотр ИД процессов в PowerShell

  3. Если в выводе требуется оставить информацию только об имени процесса и его ИД, используйте следующий синтаксис:
    Get-Process | Format-Table -Property ProcessName,Id
  4. Команда для получения информации о PID процессов с указанным именем:
    Get-Process | Where {$_.ProcessName -Like "Имя процесса"} | Format-Table -Property ProcessName,Id
    Получение PID конкретного процесса в PowerShell

На этом всё: надеюсь, подходящий для себя способ получить нужную информацию вы нашли. Знаете другие методы получения PID процессов в Windows? — буду рад вашему комментарию ниже.

What is a Process ID? How to Use PIDs for Process Management

Have you ever wondered how a computer knows which program’s output to display, especially when multiple programs are running simultaneously? This is possible because of the Process ID (PID).

A PID is a unique identifier that helps the operating system track and manage running programs.

In this article, we’ll explore what a Process ID (PID) is, why it’s important, and how you can use it to manage processes, including terminating a program when necessary.

Understanding PIDs: How Does a Computer Identify Running Programs?

Let’s consider two Python scripts:

  • hello_maham.pyprint("Hello Maham")

  • hello_amna.pyprint("Hello Amna")

How does the computer know that hello_maham.py should show the output «Hello Maham» and not «Hello Amna» from hello_amna.py?

If you think it just happens magically, then think again! This happens because of something called a Process ID (PID).

In any operating system, processes are constantly running in the background to execute tasks. Whether it’s a program you launched manually or a system task running automatically, each of these processes is assigned a unique PID.

Let’s break this down further.

Simply put,

A Process ID (PID) is a unique identifier assigned to each process running in an operating system.

Let’s understand what’s going on in the background.

Whenever a program runs, no matter the language, it needs memory and time to execute. So, when you run a program, the operating system creates a new process for it. To identify the program, the computer assigns it a unique identifier – the Process ID – and then it begins execution.

Let’s revisit our previous example:

  • When you run hello_maham.py, the system assigns a unique PID to it.

  • Similarly, when you run hello_amna.py, it gets its own unique PID.

This is why the outputs of both scripts don’t overlap!

Now, you got it? Each time a new process is created, the system ensures that every process gets a different PID. This PID is used by the system to manage and interact with processes. Its called Uniqueness Of PIDs

How Does the Computer Handle This ID?

Now you may wonder, does the computer have millions of PIDs? After all, we could be running many programs at once.

The answer is no. Once a process ends, the PID becomes available again for reuse. This means that PIDs are reusable, and there is no shortage of them.

But Why and When Do I Need PIDs?

Now that you know what a PID is, you might be wondering: Why do I need this?

Well, PIDs are actually very useful for system administrators and developers. They help in:

System admins and developers manage processes. Like, if something’s not working properly, you need to be able to find and stop the specific process causing the issue, right?

PIDs are also important for resource management. The operating system uses them to allocate memory and CPU time to each process, so no one program hogs everything.

How to Find the PID of a Running Program

Up until now, we’ve covered the theoretical concepts. Now, you might be wondering: How do I actually find the PID of a program on my computer?

Well, here are some simple ways to find the PID of a running program using various commands in the terminal.

Note, that I’ve used Bash to execute the PID command and included a screenshot for it. But for other terminals like CMD and PowerShell, the respective commands are mentioned at the end.

Some of these methods include:

1. Using the ps Command

The ps command shows a snapshot of the current running processes and their PIDs.

ps aux | grep <program_name>

Here’s an example:

ps aux | grep python

This command will display all the Python processes running on the system, along with their PIDs.

Python processes running plus their PIDs

2. Using the top Command

The top command shows real-time information about processes running on the system, including their PIDs.

top

Look under the PID column to find the process you’re interested in.

Result of running the top command

How to Kill a Process Using its PID

What if you want to kill the program? Whether it’s a cron job or a program that is misbehaving or running for too long, how can you stop it using the PID?

Let’s go through how you can do that:

1. Using the kill Command

To terminate a process, use the kill command followed by the PID:

kill <PID>

Here’s an example:

kill 1234

This command will gracefully terminate the process with PID 1234.

2. Using the kill -9 Command (Force Kill)

If the process does not stop after using the regular kill command, you can force kill it using the kill -9 command:

kill -9 <PID>

Here’s an example:

kill -9 1234

This forcefully terminates the process and bypasses any shutdown procedures it may have, so make sure you use it with caution.

How to Stop Cron Jobs Using a PID – Practical Example

So, let’s say you’ve got a cron job running, and it’s acting up. How do you stop it?

Cron jobs are scheduled tasks that run automatically at specific intervals.

If you need to stop a running cron job, you can use the PID of the process running the cron job.

Stop a Running Cron Job

If you need to stop a running cron job, you can use the PID of the process running the cron job.

Here’s how to kill a cron job:

  1. Find the PID: Use the ps or pgrep command to find the PID of the cron job. Example:

     ps aux | grep cron
    
  2. Kill the Cron Job: Once you find the PID of the cron job, use the kill or kill -9 command to stop it.

Commands For Other Terminals:

Here’s how to manage processes in different terminals:

Action CMD Command PowerShell Command Bash Command
List all processes tasklist Get-Process ps aux
Find process by name tasklist findstr <name> Get-Process
Kill process by PID taskkill /PID <PID> Stop-Process -Id <PID> kill <PID>
Force kill process taskkill /F /PID <PID> Stop-Process -Id <PID> -Force kill -9 <PID>

Conclusion

Understanding Process IDs is key to managing processes on your computer. With simple commands, you can easily find and stop problematic processes, ensuring smooth system operation.

So, stay in control of your system with PIDs!

Stay connected — @syedamahamfahim 🐬



Learn to code for free. freeCodeCamp’s open source curriculum has helped more than 40,000 people get jobs as developers. Get started

Windows 10 find Process ID

Windows 10 find Process ID
(Image credit: Future)

On Windows 10, every process from an app or a service has an identification number known as a Process ID (PID). The PID has various uses, but mainly, it exists to identify each process across the system and programs running multiple instances (such as when editing two text files with Notepad).

Although users do not have to worry about the system processes, the ability to determine their specific system number can come in handy in many scenarios. For instance, when you need to debug an app. A program is stuck, and you must terminate the process manually. Or you need to check the system resources that a particular process is using.

Regardless of the reason, Windows 10 includes at least four ways to check the PID for any process running in the system using Task Manager, Resource Monitor, Command Prompt, and PowerShell.

This guide will walk you through the steps to identify the process identification number for an app or service on Windows 10.

How to determine Process ID from Task Manager

To check the Process ID for an app on Windows 10, use these steps:

  1. Open Start.
  2. Search for Task Manager and click the top result to open the app.
  • Quick tip: You can also open the app by right-clicking the Taskbar and selecting the Task Manager option, right-clicking the Start button and selecting the Task Manager option, or using the «Ctrl + Shift + Esc» keyboard shortcut.
  • Click the Details tab.
  • Confirm the app’s Process ID in the PID column.

Task Manager Details tab process ID

(Image credit: Future)
  1. Click the Services tab.
  2. Confirm the app’s Process ID in the PID column.

Services tab PID

(Image credit: Future)

Once you complete the steps, you will know the process identification number for services and applications running and suspended on Windows 10.

How to determine Process ID from Resource Monitor

To find the Process ID for an app with the Resource Monitor console on Windows 10, use these steps:

All the latest news, reviews, and guides for Windows and Xbox diehards.

  1. Open Start.
  2. Search for Resource Monitor and click the top result to open the app.
  3. Click the Overview tab.
  4. Confirm the Process ID of apps and services in the PID column.

Resource Monitor PID view

(Image credit: Future)

After you complete the steps, you will have an overview of the ID for the running and suspended processes.

How to determine Process ID from Command Prompt

To find out the ID of a process with commands on Windows 10, use these steps:

  1. Open Start.
  2. Search for Command Prompt and click the top result to open the terminal.
  3. Type the following command to view the Process ID list and press Enter: tasklist

Command Prompt tasklist

(Image credit: Future)
  1. Type the following command to view a list of Process IDs for Microsoft Store apps and press Enter: tasklist /apps

Command Prompt tasklist apps command

(Image credit: Future)
  1. Type the following command to get the ID from the process name and press Enter: tasklist /svc /FI «ImageName eq PROCESS-NAME*»

In the command, make sure to replace PROCESS-NAME with the «.exe» name of the process. The * is a wildcard to match part of the name without having to type the exact name of the process. This example shows the processes for Notepad: tasklist /svc /FI «ImageName eq notepad*»

Command Prompt process name to ID

(Image credit: Future)

Once you complete the steps, the output will display the IDs for the processes running on the device.

How to determine Process ID from PowerShell

To determine the Process ID of an app or service with PowerShell, use these steps:

  1. Open Start.
  2. Search for PowerShell and click the top result to open the terminal.
  3. Type the following command to view the Process ID list and press Enter: Get-Process

Get-Process command

(Image credit: Future)
  1. Type the following command to view information (including ID) about a process and press Enter: Get-Process PROCESS-NAME* | Format-List *

In the command, make sure to replace PROCESS-NAME with the «.exe» name of the process. The * is a wildcard to match part of the name without having to type the exact name of the process. This example shows the Notepad Process ID and all the available information about the process: Get-Process notepad* | Format-List *

Get-Process app format-list command

(Image credit: Future)
  1. Type the following command to determine the ID and owner of the process and press Enter: Get-Process PROCESS-NAME* -IncludeUserName

In the command, make sure to replace PROCESS-NAME with the «.exe» name of the process. The * is a wildcard to match part of the name without having to type the exact name of the process. This example shows the processes for Notepad: Get-Process notepad* -IncludeUserName

Get-Process IncludeUserName

(Image credit: Future)

After you complete the steps, the PowerShell output will list the Process ID along with other information about the app or service.

More resources

For more helpful articles, coverage, and answers to common questions about Windows 10, visit the following resources:

  • Windows 11 on Windows Central — All you need to know
  • Windows 10 on Windows Central — All you need to know

Windows 11 Logo Se

Cutting-edge operating system

A refreshed design in Windows 11 enables you to do what you want effortlessly and safely, with biometric logins for encrypted authentication and advanced antivirus defenses.

Mauro Huculak has been a Windows How-To Expert contributor for WindowsCentral.com for nearly a decade and has over 15 years of experience writing comprehensive guides. He also has an IT background and has achieved different professional certifications from Microsoft, Cisco, VMware, and CompTIA. He has been recognized as a Microsoft MVP for many years.

Понравилась статья? Поделить с друзьями:
0 0 голоса
Рейтинг статьи
Подписаться
Уведомить о
guest

0 комментариев
Старые
Новые Популярные
Межтекстовые Отзывы
Посмотреть все комментарии
  • Bootrec scanos не находит windows 10
  • 80004001 код ошибки windows 10
  • Windows movie maker захват видео
  • Как увеличить скорость колесика мыши windows 10
  • Как поменять частоту кадров на мониторе windows 11