--- name: exec status: documented runtime: pp source: src/runtime/pp/process.rs --- ```{index} single: exec; Perl built-in (pp runtime) ``` # exec ## Synopsis ```perl exec("ls -la"); # shell form exec("ls", "-la"); # list form (no shell) exec { "ls" } "ls", "-l"; # indirect object form ``` ## Description Replaces the current process image with a new program via `execvp(3)`. On success, `exec` does **not return** because the current process image is replaced entirely. If `exec` does return, it means the call failed, and the return value is false. In the single-argument form, shell metacharacters trigger execution via `/bin/sh -c`. If no metacharacters are detected, the command is executed directly. In the multi-argument form, the first argument is the program and subsequent arguments are passed directly (no shell involvement). The child inherits Perl's `%ENV` (the OS environment is replaced before exec). ## See also system, fork, perlfunc/exec