---
name: "Ns_ExecArgblk"
section: "3aolserver"
platform: "linux"
package: "aolserver4-dev"
version: "4.5.1-18.1"
release: "Debian 9 (Stretch)"
platforms: ["linux"]
url: "https://new.carta.tech/Ns_ExecArgblk/3aolserver"
---

# Ns\_ExecArgblk(3aolserver)

External process execution

```

```

## NAME

Ns\_ExecArgblk, Ns\_ExecArgv, Ns\_ExecProc, Ns\_ExecProcess, Ns\_Fork, Ns\_GetEnviron,  Ns\_WaitForProcess, Ns\_WaitProcess, ns\_fork - External process execution

## SYNOPSIS

```
#include "ns.h"

int
Ns_ExecArgblk(char *exec, char *dir, int fdin, int fdout,
              char *args, Ns_Set *env)

int
Ns_ExecArgv(char *exec, char *dir, int fdin, int fdout,
            char **argv, Ns_Set *env)

int
Ns_ExecProc(char *exec, char **argv)

int
Ns_ExecProcess(char *exec, char *dir, int fdin, int fdout,
			char *args, Ns_Set *env)

int
Ns_Fork(void)

char
**Ns_GetEnviron(void)

int
Ns_WaitForProcess(int pid, int *statusPtr)

int
Ns_WaitProcess(int pid)

int
ns_fork(void)
```

## DESCRIPTION

These functions handle fork and exec operations. See files: nsd/exec.c, nsd/tclenv.c and nsthread/fork.c.

- **Ns\_ExecArgblk**(*exec, dir, fdin, fdout, args, env*)

  Executes a command in a child process. Return process id of  child process exec´ing the command or -1 on failure. Provides extended error checking and error messages.

- **Ns\_ExecArgv**(*exec, dir, fdin, fdout, argv, env*)

  Execute a command in a child process using [fork(2)](/fork/2.md) and [execve(2)](/execve/2.md), returns the process id of child process exec´ing the command or -1 on failure. The child sends an extended error message to the parent.

- **Ns\_ExecProc**(*exec, argv*)

  Executes a command in a child process. Returns the process id of the child process exec´ing the command or -1 on failure.  Simplifies call to Ns\_ExecArgv.

- **Ns\_ExecProcess**(*exec, dir, fdin, fdout, args, env*)

  Executes a command in a child process. Returns the process id of the child process exec´ing the command or -1 on failure.  Calls Ns\_ExecArgblk with same arguments.

- **Ns\_Fork**()

  Posix style fork(), using fork1() on Solaris if needed. See [fork(2)](/fork/2.md) man page. Calls ns\_fork.

- **Ns\_GetEnviron**()

  Returns pointer to the environment vector.

- **Ns\_WaitForProcess**(*pid, statusPtr*)

  Wait for child process. Returns NS\_OK on success, or  NS\_ERROR on failure. \*statusPtr is set to the exit  code of the child process.

- **Ns\_WaitProcess**(*pid*)

  Wait for child process. Calls Ns\_WaitForProcess with NULL statusPtr. Returns NS\_OK on success, or NS\_ERROR on failure.

- **ns\_fork**()

  Posix style fork(), using fork1() on Solaris if needed.

## SEE ALSO

nsd(1), [info(n)](/info/n.md)

## KEYWORDS
