---
name: "kattach"
section: "2"
platform: "linux"
package: "lam2-dev"
version: "6.3.2-3"
release: "Debian 2.2 (Potato)"
platforms: ["linux"]
url: "https://new.carta.tech/kattach"
---

# kattach(2)

Attach/detach a process to/from the local LAM daemon.

## NAME

kattach, kdetach - Attach/detach a process to/from the local LAM daemon.

## SYNOPSIS

```
int kattach (int priority);
int kdetach (int pid);
```

## DESCRIPTION

These functions allow a process to join and leave a LAM session. An existing process running under the native operating system calls *kattach()* to register with the local LAM daemon. The LAM daemon must already be running or the operation fails and an error is returned.

*kattach()* is eventually called by [kenter(2)](/kenter/2.md) and is therefore typically used in rare cases when a process wishes to change priority or return to the LAM session after temporarily detaching. *kattach()* cannot be called before [kenter(2)](/kenter/2.md). The *priority* argument determines the synchronization priority of the calling process. See [kenter(2)](/kenter/2.md).

*kdetach()* de-registers a process from the local LAM daemon. The process "dies" as far as the LAM daemon is concerned. It effectively undoes what *kattach()* did. *kdetach()* is eventually called by [kexit(2)](/kexit/2.md) and is therefore typically used in rare cases when a process wishes to leave LAM control without terminating. The *pid* argument is the process ID of the process to be detached. A process ID of 0 is interpreted as a request to detach the calling process, and is the normal usage of *kdetach()*. Detaching peer LAM processes is intended as an emergency clean up measure and is not normal usage.

## ERRORS

- ENOKERNEL

  The LAM daemon is not running.

- ENOTATTACHED

  The calling process is not a LAM process.

## SEE ALSO

[kenter(2)](/kenter/2.md), [kexit(2)](/kexit/2.md)
