# Attach to process

> **TL;DR**
> `Run | Attach to Process` `Ctrl+Alt+F5` (Windows), `⌥ ⇧ F5` (macOS), `⌥ ⇧ F5` (IntelliJ IDEA Classic (macOS)), `⌥ ⇧ F5` (macOS System Shortcuts), `Ctrl+Alt+5` (XWin), `Ctrl+Alt+5` (GNOME), `Ctrl+Alt+5` (KDE), `Ctrl+Alt+F5` (Emacs), `Ctrl+Alt+F5` (Sublime Text), `⌥ ⇧ F5` (Sublime Text (macOS)), `⌥ ⇧ F5` (Xcode), `Ctrl+Alt+P` (Visual Studio), `⌘ ⌥ P` (Visual Studio (macOS)), `Ctrl+Alt+F5` (ReSharper), `⌃ ⌥ F5` (ReSharper (macOS)), `Ctrl+Alt+F5` (QtCreator), `⌥ ⇧ F5` (QtCreator (macOS)), `Ctrl+Alt+F5` (NetBeans), `Ctrl+Alt+F5` (Eclipse), `⌥ ⇧ F5` (Eclipse (macOS))

CLion provides a way to attach the debugger to both local and remote processes.

For C/C++ applications, you can attach to a process with GDB or MSVC LLDB on Windows, LLDB on macOS, and both GDB and LLDB on Linux. When applicable, debuggers for other languages (for example, Python debugger) can be used as well.

> **Note:**
> If you want to debug a program that can be started from CLion, the best way to do it is to [start a local debugging session](starting-the-debugger-session.html).

Procedure: Prerequisites for Ubuntu

On Ubuntu and some other Linux distributions, you might get the ptrace: Operation not permitted error message upon the first attempt to attach to a process. Do one of the following:

1. To disable this restriction temporarily, enter the command:

```CONSOLE
echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope
```

2. To disable this restriction permanently, open the `/etc/sysctl.d/10-ptrace.conf` file for editing and change the line `kernel.yama.ptrace_scope = 1` to `kernel.yama.ptrace_scope = 0`.

To apply the changes immediately, enter the above command `echo 0 | sudo tee /proc/sys/kernel/yama/ptrace_scope`.

Alternatively, run `sudo service procps restart` or restart your system.

You can find more details [here](http://askubuntu.com/questions/41629/after-upgrade-gdb-wont-attach-to-process).

Procedure: Attach to a running process

1. Press `Ctrl+Alt+F5` (Windows), `⌥ ⇧ F5` (macOS), `⌥ ⇧ F5` (IntelliJ IDEA Classic (macOS)), `⌥ ⇧ F5` (macOS System Shortcuts), `Ctrl+Alt+5` (XWin), `Ctrl+Alt+5` (GNOME), `Ctrl+Alt+5` (KDE), `Ctrl+Alt+F5` (Emacs), `Ctrl+Alt+F5` (Sublime Text), `⌥ ⇧ F5` (Sublime Text (macOS)), `⌥ ⇧ F5` (Xcode), `Ctrl+Alt+P` (Visual Studio), `⌘ ⌥ P` (Visual Studio (macOS)), `Ctrl+Alt+F5` (ReSharper), `⌃ ⌥ F5` (ReSharper (macOS)), `Ctrl+Alt+F5` (QtCreator), `⌥ ⇧ F5` (QtCreator (macOS)), `Ctrl+Alt+F5` (NetBeans), `Ctrl+Alt+F5` (Eclipse), `⌥ ⇧ F5` (Eclipse (macOS)) or select `Run | Attach to Process` from the main menu.

The Attach to Process dialog opens the list of all the detected running processes.

You can view the processes as a list or as a tree and search for a particular process by name:

![Searching in the Attach to Process dialog](https://resources.jetbrains.com/help/img/idea/2026.2/cl_attachprocess_name.png)

For each process, you can find the executable name and process ID, the user that launched it, the available debuggers, and the command used for launching.

Use the drop-down menu to filter the list of processes by the type of the debugger:

![A list of debugger to attach](https://resources.jetbrains.com/help/img/idea/2026.2/cl_attach_debuggers_dropdown.png)

You can also filter the list by setting Show only my processes:

![Show only my processes in the attach to process](https://resources.jetbrains.com/help/img/idea/2026.2/cl_attach_showmyprocesses.png)

2. Attach to a local process:

The Local tab shows the list of local processes. Select the process and click Attach with....

Attach to a remote process:

Switch to the SSH tab to view the list of remote processes. Make sure to configure a [remote toolchain with SSH credentials](remote-projects-support.html#remote-toolchain) beforehand.

![Attaching to a remote process](https://resources.jetbrains.com/help/img/idea/2026.2/cl_attachtoprocess_remote.png)

On Windows, switch to the WSL tab to open the list of WSL processes. You will be able to attach to them with the WSL GDB debugger (if you have at least one [WSL toolchain](how-to-use-wsl-development-environment-in-product.html#wsl-tooclhain) configured in your project).

> **Tip:**
> You can attach to processes launched remotely with administrative privileges.

3. Proceed with [debugging](debugging-code.html) the same way you usually do it in CLion ([set breakpoints](using-breakpoints.html#set-line-breakpoint), [step through](stepping-through-the-program.html), [pause and resume](starting-the-debugger-session.html#pause)  the process, [evaluate expressions](examining-suspended-program.html#evaluating-expressions), and so on).

> **Note:**
> In case the process you have attached to does not provide debug information, breakpoints will be unavailable and stepping will be performed in the [disassembly](disassembly-view.html)  view.

Procedure: Attach to an unstarted process

If the process you would like to attach to is not running yet, you can preconfigure attachment using the Attach to an Unstarted Process action:

1. [Set the necessary breakpoints](using-breakpoints.html#set-breakpoints) in your code.

2. Select `Run | Attach to an Unstarted Process` from the main menu.

3. In the dialog that opens, specify the command line of the process or an executable name.

> **Tip:**
> To identify the process, CLion will wrap the string you supply in `*` (asterisks) and use it as a pattern to match against. Often, the executable name alone (e.g. `Terminal`) is enough. However, you can use `*` and `?` to build patterns. For example, `git.exe pu?? origin` would match both `git.exe push origin` and `git.exe. pull origin` – CLion will attach to the first matching process to start.

4. Set the Keep the process suspended after attaching checkbox if you would like the process to be paused once CLion attaches to it.

5. Clear the Reopen dialog after debug checkbox if you do not want CLion to reopen this dialog once the debugging session terminates.

6. Click Attach and select the debugger (if applicable).

![CLion awaits the indicated process](https://resources.jetbrains.com/help/img/idea/2026.2/attach_to_unstarted_process_dialog_watching.png)

CLion will begin watching. Once it identifies the process, it will automatically attach to it and trigger debugging.

Procedure: Detach from a process

The procedure of detaching from a remote process is the same as for stopping a debug session. However, note that when you detach, the debug session closes but the process continues to run.

* Click the Stop ![the Stop button](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.suspend.svg) button on the main toolbar in the [Debug tool window](debug-tool-window.html).

* Alternatively, click Stop ![the Stop button](https://resources.jetbrains.com/help/img/idea/2026.2/app.actions.suspend.svg) on the main toolbar or press `Ctrl+F2` (Windows), `⌘ F2` (macOS), `⌘ F2` (IntelliJ IDEA Classic (macOS)), `⌃ ⇧ .` (macOS System Shortcuts), `Ctrl+F2` (XWin), `Ctrl+F2` (GNOME), `Ctrl+2` (KDE), `Ctrl+F2` (Emacs), `Ctrl+F2` (Sublime Text), `Ctrl+F2` (Sublime Text (macOS)), `⌘ .` (Xcode), `Shift+F5` (Visual Studio), `⇧ F5` (Visual Studio (macOS)), `Shift+F5` (ReSharper), `⇧ F5` (ReSharper (macOS)), `Shift+F5` (QtCreator), `⌘ ⇧ Y` (QtCreator (macOS)), `Shift+F5` (NetBeans), `Ctrl+F2` (Eclipse), `⌘ F2` (Eclipse (macOS)), then select the session to be closed.

## See also

### Reference

[Debug tool window](debug-tool-window.html)

### External Links

[CLion Debugging Beyond the Basics - Part 3 - Beyond Local](https://blog.jetbrains.com/clion/2021/05/clion-debugging-beyond-the-basics-part-3-beyond-local)

