---
name: "Tcl_GetSlaves"
section: "3tcl"
platform: "linux"
package: "tcl7.6-dev"
version: "7.6p2-7"
release: "Debian 2.1 (Slink)"
platforms: ["linux"]
url: "https://carta.tech/man/CrtSlave/3tcl"
---

# Tcl\_GetSlaves(3tcl)

manage multiple Tcl interpreters and aliases.

Part of [CrtSlave(3tcl)](/man/CrtSlave/3tcl.md).

```

```

## NAME

Tcl\_IsSafe, Tcl\_MakeSafe, Tcl\_CreateSlave, Tcl\_GetSlave, Tcl\_GetSlaves, Tcl\_GetMaster, Tcl\_CreateAlias, Tcl\_GetAlias, Tcl\_GetAliases - manage multiple Tcl interpreters and aliases.

## SYNOPSIS

```
#include <tcl.h>

int
Tcl_IsSafe(interp)

int
Tcl_MakeSafe(interp)

Tcl_Interp *
Tcl_CreateSlave(interp, slaveName, isSafe)

Tcl_Interp *
Tcl_GetSlave(interp, slaveName)

Tcl_Interp *
Tcl_GetMaster(interp)

int
Tcl_GetInterpPath(askingInterp, slaveInterp)

int
Tcl_CreateAlias(slaveInterp, srcCmd, targetInterp, targetCmd, argc, argv)

int
Tcl_GetAlias(interp, srcCmd, targetInterpPtr, targetCmdPtr, argcPtr, argvPtr)
```

## ARGUMENTS

- Tcl\_Interp *\*interp* (in)

  Interpreter in which to execute the specified command.

- char *\*slaveName* (in)

  Name of slave interpreter to create or manipulate.

- int *isSafe* (in)

  Zero means the interpreter may have all Tcl functions. Non-zero means the new interpreter's functionality should be limited to make it safe.

- Tcl\_Interp *\*slaveInterp* (in)

  Interpreter to use for creating the source command for an alias (see below).

- char *\*srcCmd* (in)

  Name of source command for alias.

- Tcl\_Interp *\*targetInterp* (in)

  Interpreter that contains the target command for an alias.

- char *\*targetCmd* (in)

  Name of target command for alias in *targetInterp*.

- int *argc* (in)

  Count of additional arguments to pass to the alias command.

- char *\*\*argv* (in)

  Vector of strings, the additional arguments to pass to the alias command. This storage is owned by the caller.

- Tcl\_Interp *\*\*targetInterpPtr* (in)

  Pointer to location to store the address of the interpreter where a target command is defined for an alias.

- char *\*\*targetCmdPtr* (out)

  Pointer to location to store the address of the name of the target command for an alias.

- int *\*argcPtr* (out)

  Pointer to location to store count of additional arguments to be passed to the alias. The location is in storage owned by the caller.

- char *\*\*\*argvPtr* (out)

  Pointer to location to store a vector of strings, the additional arguments to pass to an alias. The location is in storage owned by the caller, the vector of strings is owned by the called function.

  ```

  ```

## DESCRIPTION

These procedures are intended for access to the multiple interpreter facility from inside C programs. They enable managing multiple interpreters in a hierarchical relationship, and the management of aliases, commands that when invoked in one interpreter execute a command in another interpreter. The return value for those procedures that return an **int** is either **TCL\_OK** or **TCL\_ERROR**. If **TCL\_ERROR** is returned then the **result** field of the interpreter contains an error message.

**Tcl\_CreateSlave** creates a new interpreter as a slave of the given interpreter. It also creates a slave command in the given interpreter which allows the master interpreter to manipulate the slave. The slave interpreter and the slave command have the specified name. If *isSafe* is **1**, the new slave interpreter is made \`\`safe'' by removing all unsafe functionality. If the creation failed, **NULL** is returned.

**Tcl\_IsSafe** returns **1** if the given interpreter is \`\`safe'', **0** otherwise.

**Tcl\_MakeSafe** makes the given interpreter \`\`safe'' by removing all non-core and core unsafe functionality. Note that if you call this after adding some extension to an interpreter, all traces of that extension will be removed from the interpreter. This operation always succeeds and returns **TCL\_OK**.

**Tcl\_GetSlave** returns a pointer to a slave interpreter of the given interpreter. The slave interpreter is identified by the name specified. If no such slave interpreter exists, **NULL** is returned.

**Tcl\_GetMaster** returns a pointer to the master interpreter of the given interpreter. If the given interpreter has no master (it is a top-level interpreter) then **NULL** is returned.

**Tcl\_GetInterpPath** sets the *result* field in *askingInterp* to the relative path between *askingInterp* and *slaveInterp*; *slaveInterp* must be a slave of *askingInterp*. If the computation of the relative path succeeds, **TCL\_OK** is returned, else **TCL\_ERROR** is returned and the *result* field in *askingInterp* contains the error message.

**Tcl\_GetAlias** returns information about an alias of a specified name in a given interpreter. Any of the result fields can be **NULL**, in which case the corresponding datum is not returned. If a result field is non-**NULL**, the address indicated is set to the corresponding datum. For example, if *targetNamePtr* is non-**NULL** it is set to a pointer to the string containing the name of the target command.

In order to map over all slave interpreters, use **Tcl\_Eval** with the command **interp slaves** and use the value (a Tcl list) deposited in the **result** field of the interpreter. Similarly, to map over all aliases whose source commands are defined in an interpreter, use **Tcl\_Eval** with the command **interp aliases** and use the value (a Tcl list) deposited in the **result** field. Note that the storage of this list belongs to Tcl, so you should copy it before invoking any other Tcl commands in that interpreter.

## SEE ALSO

For a description of the Tcl interface to multiple interpreters, see *[interp(n)](/man/interp/n.md)*.

## KEYWORDS

alias, command, interpreter, master, slave
