---
name: "TAU_REGISTER_FORK"
section: "3"
platform: "linux"
package: "tau"
version: "2.17.3.1.dfsg-4.2"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/TAU_REGISTER_FORK"
---

# TAU\_REGISTER\_FORK(3)

Informs the measurement system that a fork has taken place

## NAME

TAU\_REGISTER\_FORK - Informs the measurement system that a fork has taken place

## SYNOPSIS

**C/C++:**

**TAU\_REGISTER\_FORK(int** *pid***, enum TauFork\_t** *option***);**

## DESCRIPTION

To register a child process obtained from the fork() syscall, invoke the TAU\_REGISTER\_FORK macro. It takes two parameters, the first is the node id of the child process (typically the process id returned by the fork call or any 0..N-1 range integer). The second parameter specifies whether the performance data for the child process should be derived from the parent at the time of fork ( TAU\_INCLUDE\_PARENT\_DATA ) or should be independent of its parent at the time of fork ( TAU\_EXCLUDE\_PARENT\_DATA ). If the process id is used as the node id, before any analysis is done, all profile files should be converted to contiguous node numbers (from 0..N-1). It is highly recommended to use flat contiguous node numbers in this call for profiling and tracing.

## EXAMPLE

**C/C++ :**

```
pID = fork();
if (pID == 0) {
  printf("Parent : pid returned %d\n", pID)
}  else {
  // If we'd used the TAU_INCLUDE_PARENT_DATA, we get
  // the performance data from the parent in this process
  // as well.
  TAU_REGISTER_FORK(pID, TAU_EXCLUDE_PARENT_DATA);
  printf("Child : pid = %d", pID);
}
```
