---
name: "Ns_Exec"
section: "3"
platform: "linux"
package: "aolserver4"
version: "4.0.10-7"
release: "Debian 4.0 (Etch)"
platforms: ["linux"]
url: "https://new.carta.tech/Ns_Exec"
---

# Ns\_Exec(3)

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) 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
