---
name: "p_candebug"
section: "9"
platform: "linux"
package: "freebsd-manpages"
version: "6.0-5"
release: "Debian 4.0 (Etch)"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/p_candebug"
---

# p\_candebug(9)

determine debuggability of a process

## NAME

**p\_candebug** – determine debuggability of a process

## SYNOPSIS

**#include \<sys/proc.h\>**

*int*\

**p\_candebug**(*struct thread \*td*, *struct proc \*p*);

## DESCRIPTION

This function can be used to determine if a given process *p* is debuggable by the thread *td*.

## SYSCTL VARIABLES

The following [sysctl(8)](/sysctl/8.md) variables directly influence the behaviour of **p\_candebug**():

- *kern.securelevel*

  Debugging of the init process is not allowed if this variable is 1 or greater.

- *security.bsd.unprivileged\_proc\_debug*

  Must be set to a non-zero value to allow unprivileged processes access to the kernel's debug facilities.

## RETURN VALUES

The **p\_candebug**() function returns 0 if the process denoted by *p* is debuggable by thread *td*, or a non-zero error return value otherwise.

## ERRORS

- \[EACCESS\]

  The MAC subsystem denied debuggability.

- \[EAGAIN\]

  Process *p* is in the process of being **exec**(*Ns*, *'ed.*)

- \[EPERM\]

  Thread *td* lacks super-user credentials and process *p* is executing a set-user-ID or set-group-ID executable.

- \[EPERM\]

  Thread *td* lacks super-user credentials and process *p*'s group set is not a subset of *td*'s effective group set.

- \[EPERM\]

  Thread *td* lacks super-user credentials and process *p*'s user IDs do not match thread *td*'s effective user ID.

- \[EPERM\]

  Process *p* denotes the initial process **initproc**() and the [sysctl(8)](/sysctl/8.md) variable *kern.securelevel* is greater than zero.

- \[ESRCH\]

  Process *p* is not visible to thread *td* as determined by [cr\_seeotheruids(9)](/cr_seeotheruids/9.md) or [cr\_seeothergids(9)](/cr_seeothergids/9.md).

- \[ESRCH\]

  Thread *td* has been jailed and process *p* does not belong to the same jail as *td*.

- \[ESRCH\]

  The MAC subsystem denied debuggability.

## SEE ALSO

[intro(2)](/intro/2.md), [jail(2)](/jail/2.md), [sysctl(8)](/sysctl/8.md), [cr\_seeothergids(9)](/cr_seeothergids/9.md), [cr\_seeotheruids(9)](/cr_seeotheruids/9.md), [mac(9)](/mac/9.md), [prison\_check(9)](/prison_check/9.md)
