Sign in Join
FPDoc Onlineexperiment

FpExecve function

In unit BaseUnix

Execute process using environment.

Declaration

pascal
function FpExecve(path: PAnsiChar; argv: PPAnsiChar; envp: PPAnsiChar)
: cint

Description

Replaces the currently running program with the program, specified in path. It gives the program the options in argv, and the environment in envp. They are pointers to an array of pointers to null-terminated strings. The last pointer in this array should be nil. On success, execve does not return.

Errors

Extended error information can be retrieved with fpGetErrno, and includes the following:

sys_eacces
File is not a regular file, or has no execute permission. A component of the path has no search permission.
sys_eperm
The file system is mounted noexec .
sys_e2big
Argument list too big.
sys_enoexec
The magic number in the file is incorrect.
sys_enoent
The file does not exist.
sys_enomem
Not enough memory for kernel.
sys_enotdir
A component of the path is not a directory.
sys_eloop
The path contains a circular reference (via symlinks).

See also

Example: ex7

pascal
Program Example7;

{ Program to demonstrate the Execve function. }

Uses BaseUnix, strings;

Const Arg0 : PChar = '/bin/ls';
      Arg1 : Pchar = '-l';

Var PP : PPchar;


begin
  GetMem (PP,3*SizeOf(Pchar));
  PP[0]:=Arg0;
  PP[1]:=Arg1;
  PP[3]:=Nil;
  { Execute '/bin/ls -l', with current environment }
  { Envp is defined in system.inc }
  fpExecVe ('/bin/ls',pp,envp);
end.

An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.