# attach\_process

```
Attach the debugger to a running process
     pid - PID of the process to attach to. If NO_PROCESS, a dialog box
           will interactively ask the user for the process to attach to.
     event_id - reserved, must be -1
returns:
        -2 - impossible to find a compatible process
        -1 - impossible to attach to the given process (process died, privilege
             needed, not supported by the debugger plugin, ...)
         0 - the user cancelled the attaching to the process
         1 - the debugger properly attached to the process
See the important note to the step_into() function

long attach_process(long pid, long event_id);
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.hex-rays.com/9.0/developer-guide/idc/idc-api-reference/alphabetical-list-of-idc-functions/12.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
